I want to get data from on-chain that is not explicitly available through a getter. For example, if I know that there is data at position 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc at address 0xd0A7333587053A5BAe772BD37b9AAe724E367619, how can I retrieve that data if there is no getter function in the contract?

  • Yes, the answer is the same, however the question is being asked is different. Someone may be looking for the answer to this question, but may not find the other questions based on search results. Similarly, a search for the other question would most certainly not produce this question. Jun 11 '20 at 22:56

You can retrieve any piece of data from any on-chain contract if you know the location that the data is stored. You can do this by using the getStorage RPC call or through any web3 library.

For your specific question, you can retrieve the data a few ways:


> ethersProvider.getStorageAt('0xd0A7333587053A5BAe772BD37b9AAe724E367619', '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc')



> web3.eth.getStorageAt('0xd0A7333587053A5BAe772BD37b9AAe724E367619', '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc')



> curl -X POST --data '{"jsonrpc":"2.0", "method": "eth_getStorageAt", "params": ["0xd0A7333587053A5BAe772BD37b9AAe724E367619", "0x0", "latest"], "id": 1}' localhost:8545


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