Last active
December 21, 2020 20:37
-
-
Save petejkim/ee5462c1109bdfc13a9875bce0524e53 to your computer and use it in GitHub Desktop.
USDC v2: Upgrading a $1.4B Token - sload/sstore example
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
contract Foo { | |
bytes32 private constant NUM_SLOT = keccak256("Foo.num"); | |
function num() public view returns (uint256 val) { | |
bytes32 slot = NUM_SLOT; | |
assembly { | |
val := sload(slot) | |
} | |
} | |
function setNum(uint256 val) public { | |
bytes32 slot = NUM_SLOT; | |
assembly { | |
sstore(slot, val) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment