Skip to main content

eth_getStorageAt

   curl --request POST \
--url https://ethereum-mainnet-geth-archive.node.coinapi.io \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"params": [
"0xe5cB067E90D5Cd1F8052B83562Ae670bA4A211a8",
"latest"
],
"method": "eth_getCode"
}'

Overview

The 'eth_getStorageAt' method returns the value from a storage position at a given address.

Request

replace 'mainnet' with any other supported network.

Request Parameters

  • 'address': [ Required ] A string representing the address (20 bytes) of the storage.
  • 'storage positio'n: [ Required ] A hexadecimal code of the position in the storage.
  • 'block parameter': [ Required ] A hexadecimal block number, or the string 'latest', 'earliest' or 'pending'. Refer to the default block parameter section for more details.

Response

{
"jsonrpc": "2.0",
"id": 1,
"result": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
  • 'storage value': A hexadecimal equivalent of the integer indicating the value of the storage position at the provided address.

Notes on Storage Retrieval:

  • Calculating the correct position depends on the storage to retrieve. For instance, consider the following contract deployed at '0x407d73d8a49eeb85d32cf465507dd71d507100c1' by address '0x391694e7e0b0cce554cb130d723a9d27458f9298':
contract Storage {
uint pos0;
mapping (address => uint) pos1;
function Storage() {
pos0 = 1234;
pos1[msg.sender] = 5678;
}
}

Retrieving the value of 'pos0' is straightforward. However, retrieving an element of the map requires a more complex calculation. The position of an element in the map is calculated using the 'keccak' function and padding techniques. Tools like the geth console which comes with the web3 library can be used to make these calculations.