⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

eth_getStorageAt

Returns the value from a storage position at a given address.

When to Use This Method

Use eth_getStorageAt to:

  • Read Storage Variables - Access contract state directly
  • Debug Contracts - Inspect storage slots
  • Verify State - Check storage without calling functions
  • Analyze Data - Read raw storage data
  • Security Research - Examine contract internals

Parameters

  1. Address - DATA, 20 Bytes

    • Address of the storage
  2. Position - QUANTITY

    • Storage position (slot)
  3. Block Parameter - QUANTITY|TAG

    • latest, earliest, pending, or block number
{
"jsonrpc": "2.0",
"method": "eth_getStorageAt",
"params": [
"0x295a70b2de5e3953354a6a8344e616ed314d7251",
"0x0",
"latest"
],
"id": 1
}

Returns

DATA - The value at this storage position.

Implementation Examples

import { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider('https://api-zetachain-mainnet.n.dwellir.com/YOUR_API_KEY');

// Read storage slot 0
const contractAddress = '0x295a70b2de5e3953354a6a8344e616ed314d7251';
const slot = '0x0';
const value = await provider.getStorageAt(contractAddress, slot);
console.log('Storage value:', value);

// Read mapping value
function getMapLocation(key, slot) {
return ethers.keccak256(
ethers.concat([
ethers.zeroPadValue(key, 32),
ethers.zeroPadValue(slot, 32)
])
);
}

const userAddress = '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb8';
const balanceSlot = '0x1'; // Assuming balances mapping is at slot 1
const userBalanceSlot = getMapLocation(userAddress, balanceSlot);
const balance = await provider.getStorageAt(contractAddress, userBalanceSlot);