Created
April 3, 2023 05:11
-
-
Save KolevDarko/6be6ad9965085e08492c67790b8451c5 to your computer and use it in GitHub Desktop.
Solidity dynamic array assembly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function readBigArrayLocation(uint256 index) external view returns (uint256 ret) { | |
uint256 slot; | |
assembly{ | |
slot := bigArray.slot | |
} | |
bytes32 location = keccak256(abi.encode(slot)); | |
assembly{ | |
ret := sload(add(location, index)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment