eth_getStorageAt - Ethereum

Retrieve the value of a storage position at a specified address using eth_getStorageAt. Essential for accessing specific data stored within smart contracts on the Ethereum blockchain

This method returns the value of a storage position at a specified address, allowing developers to access specific data stored within smart contracts.

The Ethereum eth_getStorageAt method is part of the Ethereum JSON RPC Core API, used to interact with Ethereum nodes. The eth_getStorageAt RPC Ethereum method is essential for retrieving on-chain data directly from the storage of a contract.

Supported Networks

The eth_getStorageAt RPC Ethereum method supports the following network types

  • Mainnet

  • Testnet: Sepolia, Holesky

Parameters

  • DATA: The 20-byte address of the storage (account or contract) for which to retrieve the storage value.

  • DATA: The integer index of the storage position to access.

  • QUANTITY | TAG: An integer representing a block number or one of the string tags latest, earliest, or pending, as described in Block Parameter.

Request

URL (API Endpoint)

https://go.getblock.io/<ACCESS-TOKEN>/

To make a request, send a JSON object with the jsonrpc, method, and params fields. Below is an example of how to make a request using curl, eth_getStorageAt example:

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_getStorageAt",
    "params": [
        "0x9EC55d57208cb28a7714A2eA3468bD9d5bB15125",
        "0x0",
        "latest"
    ],
    "id": "getblock.io"
}'

Response

The server responds with a JSON object containing the value at the specified storage position. Below is an example of a typical response

{
    "id": "getblock.io",
    "jsonrpc": "2.0",
    "result": "0x0000000000000000000000000000000000000000000000000000000000000000"
}

Response Description

  • result: The value at the specified storage position, represented as a hexadecimal string.

Use Case

The eth_getStorageAt method is particularly useful for developers who need to retrieve specific storage values from smart contracts on the Ethereum blockchain. This can be used for debugging or for accessing critical data stored within a contract. In case of an eth_getStorageAt error, developers should ensure that the provided address, storage index, and block tag are correct.

Code Example

You can also make requests to the eth_getStorageAt method programmatically using Python. Below is an example using the requests library:

import requests
import json

# Define the API URL and access token
url = 'https://go.getblock.io/<ACCESS-TOKEN>/'
headers = {'Content-Type': 'application/json'}

# Prepare the request data
data = {
    "jsonrpc": "2.0",
    "method": "eth_getStorageAt",
    "params": [
        "0x9EC55d57208cb28a7714A2eA3468bD9d5bB15125",
        "0x0",
        "latest"
    ],
    "id": "getblock.io"
}

# Send the POST request
response = requests.post(url, headers=headers, data=json.dumps(data))

# Parse the JSON response
response_data = response.json()

# Print the result
print(json.dumps(response_data, indent=4))

This Python script sends a request to the eth_getStorageAt method and prints the returned storage value. Make sure to replace <ACCESS-TOKEN> with your actual API token.

Web3 eth_getStorageAt libraries , providing an interface to access contract storage data for various use cases, including contract interaction, debugging, and data analysis.

Last updated

© 2019-2024 GetBlock LLC. All rights reserved ID: 21835790. Address: Belgrade, Serbia.