Created
April 3, 2023 05:22
-
-
Save KolevDarko/2f0e3b790a6f0e600d9a735026f06dfe to your computer and use it in GitHub Desktop.
Solidity access mapping
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 getMapping(uint256 key) external view returns (uint256 ret) { | |
uint256 slot; | |
assembly{ | |
slot := myMapping.slot | |
} | |
bytes32 location = keccak256(abi.encode(key, uint256(slot))); | |
assembly{ | |
ret := sload(location) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment