1

What tools or methods exist for querying arbitrary contract storage?

The problem at hand is having to inspect smart contract state variables that have been marked as internal. Block explorers, Remix, and other tools only make it easy to query public state.

2

2 Answers 2

2

You can open truffle console connected to a public node if you want. Then you can use the api call web3.eth.getStorage(address, slot) to get the data at individual storage slots. I don't know of any tool you can easily plug a smart contract and have it tell you want slot each variable is at, but generally the state variables are in order by declaration. It'll likely vary slightly though.

0

With 0xweb tool you can install validated contracts locally; one feature is to list and read all variables.

$ npm i 0xweb -g
$ 0xweb i 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 --name USDC --chain eth
$ 0xweb c vars USDC --chain eth
$ 0xweb c var USDC _owner --chain eth

It lists and also reads private variables.

You can also save all state variables of the contract:

0xweb c dump USDC --chain eth

Public nodes are used, that have rate-limits, you should add your rpc node for eth with 0xweb config -e

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.