eth_getStorageAt - Monad

This method returns the value from a storage position at a given address.

Parameters

ParameterTypeRequiredDescription
addressstringYesThe address of the storage.
positionstringYesThe storage position (hex).
blockNumberstringNoBlock number in hex, or "latest", "earliest", "pending", "safe", "finalized".

Request

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

example.js

javascriptimport axios from 'axios';

const data = JSON.stringify({
    "jsonrpc": "2.0",
    "method": "eth_getStorageAt",
    "params": ["0xdAC17F958D2ee523a2206206994597C13D831ec7", "0x0", "latest"],
    "id": "getblock.io"
});

const config = {
    method: 'post',
    url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers: {
        'Content-Type': 'application/json'
    },
    data: data
};

axios(config)
    .then(response => console.log(JSON.stringify(response.data)))
    .catch(error => console.log(error));

example.py

pythonimport requests
import json

url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"

payload = json.dumps({
    "jsonrpc": "2.0",
    "method": "eth_getStorageAt",
    "params": ["0xdAC17F958D2ee523a2206206994597C13D831ec7", "0x0", "latest"],
    "id": "getblock.io"
})

headers = {
    'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers, data=payload)
print(response.text)

example.rs

rustuse reqwest::header;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();
    
    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header(header::CONTENT_TYPE, "application/json")
        .body(r#"{
            "jsonrpc": "2.0",
            "method": "eth_getStorageAt",
            "params": ["0xdAC17F958D2ee523a2206206994597C13D831ec7", "0x0", "latest"],
            "id": "getblock.io"
        }"#)
        .send()
        .await?;
    
    println!("{}", response.text().await?);
    Ok(())
}

Response

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

Response Parameters

FieldTypeDescription
resultstringThe value at the storage position (32 bytes, hex encoded).

Calculating Storage Slots

For mappings and dynamic arrays, use keccak256 to calculate the slot:

calculate-slot.js

javascriptimport { ethers } from 'ethers';

// For mapping: mapping(address => uint256)
// Storage slot = keccak256(abi.encode(key, mappingSlot))
const key = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb';
const mappingSlot = 0; // First state variable

const slot = ethers.keccak256(
    ethers.AbiCoder.defaultAbiCoder().encode(
        ['address', 'uint256'],
        [key, mappingSlot]
    )
);

Use Case

The eth_getStorageAt method is essential for:

  • Reading contract state directly
  • Analyzing contract storage layout
  • Security auditing
  • Verifying contract state without ABI
  • Debugging contract behavior
  • Historical state analysis

Error Handling

Status CodeError MessageCause
403ForbiddenMissing or invalid ACCESS-TOKEN.
-32602Invalid paramsInvalid address or position format.
-32000Resource not foundBlock not found.

Web3 Integration

ethers.js

javascriptimport { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');

// Read storage slot 0
const value = await provider.getStorage(contractAddress, 0);
console.log('Slot 0:', value);

// Read specific slot
const slot = '0x0000000000000000000000000000000000000000000000000000000000000001';
const value1 = await provider.getStorage(contractAddress, slot);
console.log('Slot 1:', value1);

web3.js

javascriptimport { createPublicClient, http } from "viem";
import { monad } from "viem/chains";

// Create Viem client with GetBlock
const client = createPublicClient({
  chain: monad,
  transport: http(
    import.meta.env.MONAD_ACCESS_TOKEN
  ),
});

// Using the method through Viem
async function Call() {
  try {
    // Method-specific Viem implementation
    const result = await client.request({
      method: "eth_getStorageAt",
      params: ["0xdAC17F958D2ee523a2206206994597C13D831ec7", "0x0", "latest"],
    });
    console.log("Result:", result);
    return result;
  } catch (error) {
    console.error("Viem Error:", error);
    throw error;
  }
}