The eth_getStorageAt
method returns the value stored at a specific storage position for a given smart contract address. This low-level method allows direct access to the contract's state variables and is crucial for contract analysis and debugging.
This method provides raw access to any storage slot in a contract's storage.
The address of the smart contract
The integer of the storage position (hex string)
Block number in hex format or block tag
The value at the specified storage position (32 bytes, hex encoded)
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x000000000000000000000000000000000000000000000000000000000000000a"
}
Solidity's storage layout follows specific rules:
// Storage slot 0
uint256 firstVariable;
// Storage slot 1
address secondVariable;
// Storage slot 2 (empty)
mapping(address => uint256) balances;
// Value stored at keccak256(abi.encode(userAddress, 2))
keccak256(slot)
// Storage slot 3 has length
uint256[] myArray;
// Values stored at keccak256(3) + index
// All in storage slot 4
uint128 a;
uint64 b;
uint64 c;
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc
For complex contracts, consider using dedicated tools: