eth_getStorageAt¶
Query the value of a contract storage slot.
- Source:
framework/src/main/java/org/tron/core/services/jsonrpc/TronJsonRpcImpl.java#getStorageAt - Ports: FullNode
8545/ Solidity8555
Request parameters¶
| Position | Type | Required | Description |
|---|---|---|---|
params[0] |
string | yes | Contract address: 20-byte hex or 21-byte Tron hex beginning with 41, with or without 0x (base58check is not accepted) |
params[1] |
string | yes | Storage slot index, hex-encoded with or without 0x; values shorter than 32 bytes are left-padded with zeros |
params[2] |
string | yes | Block tag, only latest is supported |
curl -X POST https://nile.trongrid.io/jsonrpc \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","method":"eth_getStorageAt","params":["0x9ff8fc48fb114ccd5bbdc24a86f0c73082f08825","0x0","latest"],"id":1}'
Response¶
The 32-byte slot value, hex-encoded. Returns 32 bytes of zeros when the address is not a contract or the slot has never been written.
The example below is the real response captured from the Nile testnet curl above (the contract's slot 0 holds a uint256 counter with value 0x8):
{ "jsonrpc": "2.0", "id": 1, "result": "0x0000000000000000000000000000000000000000000000000000000000000008" }
Error responses¶
| Trigger | Code | message |
|---|---|---|
params[2] is earliest / pending / finalized / safe |
-32602 |
TAG [earliest \| pending \| finalized \| safe] not supported |
params[2] is a valid hex or decimal number |
-32602 |
QUANTITY not supported, just support TAG as latest |
params[2] is neither a valid tag nor a valid non-negative hex/decimal number |
-32602 |
invalid block number |
params[0] is not a valid address |
-32602 |
passes through the message |
params[1] is null, too long, or cannot be decoded as a valid storage key |
-32602 |
invalid storage key value |