15

Given a contract, how can I find out the current value of one of its variables (as a dev, not from the context of another contract), if it's not public?

14

If you know the location in storage, you can use web3

eth.getStorageAt(address, location)

The variables are generally sequential, the first variable declared is in position 0, the second in position 1, etc.

For dynamic arrays, their position contains the length of the array, and the data starts at sha3(position)

| improve this answer | |
  • I guess this no longer works, now it accepts some other parameter called key , it is not clear wheter its a variable name or what – Nulik May 14 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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