Given the contract variable mapping(address => uint64[]) public foo
, can anyone help me access the data using web3?
Assuming we have the account address (0xF89...
) and that foo
is in slot 5, I can access the length of the array using:
key = '00000000000000000000000xF895a7D153d80A52aE9C32C30400e000censored'
index = '0000000000000000000000000000000000000000000000000000000000000005'
let varAddress = web3.sha3(key + index, {"encoding":"hex"}) // k . p
let res = web3.eth.getStorageAt(contractAddress, varAddress);
But I haven't been able to figure out how to access the data in the array itself.
I've been trying to decipher the relevant section in Layout of State Variables in Storage, and this article was also helpful, but can't quite get it. Any help?