12

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?

12

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)

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.