Skip to content

Instantly share code, notes, and snippets.

@KolevDarko
Created April 3, 2023 05:11
Show Gist options
  • Save KolevDarko/6be6ad9965085e08492c67790b8451c5 to your computer and use it in GitHub Desktop.
Save KolevDarko/6be6ad9965085e08492c67790b8451c5 to your computer and use it in GitHub Desktop.
Solidity dynamic array assembly
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