Skip to main content

eth_getStorageAt

Retrieves the value from a storage position at a given address on the Base network. This method allows direct access to contract storage slots, enabling you to read contract state variables, proxy implementation addresses, and other stored data.

Parameters​

ParameterTypeRequiredDescription
addressstringYesThe 20-byte address of the contract whose storage you want to read
positionstringYesThe hex-encoded storage position/slot number (32 bytes)
blockNumberstringYesBlock number in hex, or block tag ("latest", "earliest", "pending")

Storage Position Calculation​

  • Simple variables: Use slot number directly (e.g., 0x0, 0x1, 0x2)
  • Mappings: keccak256(key + slot) where key is padded to 32 bytes
  • Arrays: Length at slot, elements at keccak256(slot) + index
  • Structs: Each field occupies consecutive slots

Returns​

Returns a 32-byte hex string representing the storage value. Values are left-padded with zeros if smaller than 32 bytes.

Code Examples​

# Read storage slot 0 from USDC contract on Base
curl -X POST https://api-base-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getStorageAt",
"params": [
"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"0x0",
"latest"
],
"id": 1
}'

Response Example​

{
"jsonrpc": "2.0",
"id": 1,
"result": "0x0000000000000000000000000000000000000000000000000000000000000001"
}

Use Cases​

  • Contract State Inspection: Read private or internal variables
  • Proxy Implementation: Get implementation address from proxy contracts
  • Token Balances: Access balance mappings directly
  • Access Control: Check role assignments and permissions
  • Debugging: Investigate contract state during development

Important Notes​

  • Storage values are always 32 bytes (64 hex characters plus 0x prefix)
  • Unused storage slots return 0x0000000000000000000000000000000000000000000000000000000000000000
  • Storage layout depends on Solidity version and compiler optimizations
  • For dynamic arrays, slot contains length; actual data starts at keccak256(slot)
  • Packed structs may share storage slots for gas optimization

Need help? Contact our support team or check the Base documentation.