1

I found at here, that it is possible for a client to get the value from storage of a contract at a particular index using eth.getStorageAt(contract_address, index) interface. I wanted to ask

Is it possible to download the complete storage of a smart contract using geth client?

I tried writing a script consisting of a loop to execute this call repeatedly, but the problem with this approach is that for out of range index it always returns 0x0 which is ambiguous if the client does not know the size of the storage. Which leads me to the question

Is it possible to find the size of the storage occupied by a smart contract?

  • It will be impossible to iterate over the storage. It's (virtual) size is 2^256 x 256bits and everything is virtually initialised with 0. Moreover, simple fields start at index 0, but more complex things like mappings for instance, will be somewhere in your storage depending on the hash of the path in the mapping. However, I am not 100% sure how to dump the storage with means provided by the console. One way could be to trace all the transactions sent to the contract. AFAIK, after each step, you'll have the storage changes in the output. – ivicaa Feb 19 '18 at 20:49
  • Thanks, @ivicaa Basically I am looking for a way to get the complete state of an ethereum smart contract. Using eth.getCode() we can get the code of a contract, similarly for the balance and nonce. I could not find anything similar for storage. So is there a possibility of getting the whole state of a smart contract from blockchain using geth client? – sourav Feb 20 '18 at 5:46

Your Answer

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

Browse other questions tagged or ask your own question.