Solidity Storage Values Analysis
Last updated
Last updated
Reference:
In Solidity, each data type has the following size:
bool
1
bytes1
1
bytes8
8
bytes16
16
bytes32
32
address
20
contract
20
uint8/int8
1
uint16/int16
2
uint32/int32
4
uint64/int64
8
uint128/int128
16
uint256/int256
32
Reference: https://coinsbench.com/12-privacy-ethernaut-explained-8ee480f303f2
Below is the Solidity contract example.
The Solidity’s each slot can store data until 32 bytes. For example below, the ‘Slot 2’ stores multiple variables because each value is just 1 byte, which are 2 bytes in total so less than 32 bytes.
Using Web3.js, we can get values of the above variables from outside.
There are methods to see the storage slot values in appropriate format.