I want to know how this works: web3.eth.getStorageAt(addressHexString, position [, defaultBlock] [, callback])

What data we can store at any address and how? And what will this eth API return?

up vote 8 down vote accepted

Each contract consists of a EVM bytecode handling the execution and a storage to save the state of the contract. This is a low level function to get the state of the contract's storage. The storage is essentially a key/value store.
The function returns the value the contracts storage has at a certain position.

Refer to the GitHub wiki pages.

More on storage here.

for instance if you look at this contract source and you type this in geth:


it returned the following

  • Would you be able to also provide an example for getting the address of a dynamic array? i've tried with web3.sha3("0x01") to calculate the address but can't figure it out. – slothbag Jun 27 '16 at 23:53

As of version 1.0 of web3.js, the web3.utils.hexToAscii function should be used. Correct syntax:

web3.eth.getStorageAt('/* Contract Address */', 0).then(result => {

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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