I try to reverse engineer a smart contract on ethereum. Now I want to retrieve all used/changed storage from a contract via web3. Is this possible? I understand, that I cannot get keys to e.g. mappings, since they are used only in hashed form (like function names), but I think it should be possible to get all storage which was changed since the contract exists. But how?

1 Answer 1


if you have access to the source code you can see the storage layout and figure out all the storage locations for a contract's variables. You can retrieve the values at these locations using web3.js or ethers.js getStorageAt.

here are some links that show accessing contract storage with web3/ethers https://www.youtube.com/watch?v=C9C4zgskHwg https://www.youtube.com/watch?v=Gg6nt3YW74o https://solidity-by-example.org/hacks/accessing-private-data/

otherwise, you could go through all the transactions associated with a contract and figure out what changes have been made.

You can see some data in storage slots and changes from transactions of that with etherscan.io

here's completely random example [https://etherscan.io/tx/0x98c6b4488501e6b932de4dccbf399736976810e4608baf79dbe5df68629a5832#statechange][1]

expand the state change area, you can see how the transaction changed the values at storage slots 0 and 10 and two other storage addresses designated with 32byte hashes. You can find a contract's deployment transaction to view the changes at deployment. Within the state change area you can change the view of the bytes32 data from hex to number / text / address as a quick way to see if it makes sense as another datatype

  • Thank you very much. Can you please provide an example of etherscan showing changes? Then I'll mark your answer as solved. Commented Aug 23, 2022 at 17:49
  • ok. I've added a bit as requested
    – sola24
    Commented Aug 23, 2022 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.