Skip to content

Instantly share code, notes, and snippets.

@jamesmorgan
Last active March 3, 2023 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesmorgan/95d0eede2544c5a9b93aea77624013ca to your computer and use it in GitHub Desktop.
Save jamesmorgan/95d0eede2544c5a9b93aea77624013ca to your computer and use it in GitHub Desktop.
contract Sample {
uint256 a; // storage position 0
uint256[2] b; // storage position 1 & 2
// This is just declaration
struct TestStruct {
uint256 id;
uint256 value;
}
TestStruct c; // Initialization with default values. storage position 3 & 4
uint256 d; //storage position 5
mapping(uint256 => uint256) e; // storage position 6
mapping(uint256 => uint256) f; // storage position 7
// In case of e, for an arbitrary key 4 and value 10, the storage determines the slot by hashing keccak256(4, 1)
// In case of f, for an arbitrary key 4 and value 11, the storage determines the slot by hashing keccak256(4, 2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment