contract Storage {
bytes arr;
function storeArr(bytes memory _arr) public {
arr = _arr;
}
}Calling storeArr(0xb0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0) (32 bytes) we get this in the storage.
Slot 0x00 has:
>>> web3.eth.getStorageAt("0x958b09DB711753a68089A0305d4fac915Bc76369", 0x00)
HexBytes('0x41')And the actual array data is stored at keccak(0x0000000000000000000000000000000000000000000000000000000000000000):
>>> web3.eth.getStorageAt("0x958b09DB711753a68089A0305d4fac915Bc76369", int(keccak(hexstr=("00"*32)).hex(), 16))
HexBytes('0xb0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0')Calling storeArr(0xb1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1) (33 bytes) we get this in the storage.
We get the length of the stored data:
>>> web3.eth.getStorageAt("0x958b09DB711753a68089A0305d4fac915Bc76369", 0x00)
HexBytes('0x43')The first word containing 32 bytes:
>>> web3.eth.getStorageAt("0x958b09DB711753a68089A0305d4fac915Bc76369", int(keccak(hexstr=("00"*32)).hex(), 16))
HexBytes('0xb1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1')The second word containing the remaining 1 byte:
>>> web3.eth.getStorageAt("0x958b09DB711753a68089A0305d4fac915Bc76369", int(keccak(hexstr=("00"*32)).hex(), 16) + 1)
HexBytes('0xb100000000000000000000000000000000000000000000000000000000000000')