BNB Smart Chain

BNB Smart Chain

debug_storageRangeAt

eth_getStorageAt reads one slot at a block boundary. debug_storageRangeAt goes much deeper: it walks a contract's storage slots in pages, starting from a key hash you supply and returning up to your requested limit, captured at the state that exists immediately after a specific transaction inside a block. On BNB Smart Chain (BSC), where BEP-20 contracts power apps such as Venus and PancakeSwap and gas is paid in BNB, that mid-block snapshot is exactly what an incident review needs. Issue the call against chain ID 56 at https://bsc.therpc.io/YOUR_API_KEY. The method rebuilds historical state, which is heavy work, so it leans on a debug-enabled archive node.

Use cases

  • Dump the full storage layout of a BEP-20 token or vault contract at one precise execution point for an incident post-mortem.
  • Check that slot assignments in an upgradeable proxy line up with the layout the implementation contract expects.
  • Diff a contract's storage just before and just after a suspicious transaction to see which slots the attacker touched.

Parameters

#NameTypeRequiredDescription
1blockHashstringYesHash of the block containing the transaction of interest.
2txIndexintegerYesIndex of the transaction within the block after whose execution the storage is read.
3contractAddressstringYesAddress of the contract whose storage to inspect.
4startKeystringYesStorage key hash from which to begin iteration. Use `0x0000…0000` to start from the beginning.
5limitintegerYesMaximum number of storage entries to return in one call.

Response

TypeDescription
object`{storage: Record<keyHash, {key: string, value: string}>, nextKey?: string}` — `nextKey` is present when more entries follow and can be passed as `startKey` for the next page.

Example request

curl https://bsc.therpc.io/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "debug_storageRangeAt",
"params": [
"0x0000000000000000000000000000000000000000000000000000000000000000",
0,
"0x8894E0a0c962CB723c1976a4421c95949bE2D4E3",
"0x0000000000000000000000000000000000000000000000000000000000000000",
5
],
"id": 1
}'

Try it live in the BNB Smart Chain playground.

Errors & troubleshooting

CodeMessageCause
-32601Method not founddebug namespace not enabled on the node.
-32602Invalid paramsAny required parameter is missing, malformed, or txIndex is out of range for the block.
-32000block not foundBlock hash not found or the node lacks state for that block (archive node required for historical blocks).

Common pitfalls

  • Keys come back as raw keccak256 hashes, so you rebuild mapping entries and dynamic-array slots by hand from the original key preimages.
  • Historical blocks require full archive state. A pruned node answers only for the most recent window.
  • A large contract holds thousands of slots and returns a bulky response, so set a sensible limit and follow nextKey page by page. Expect throttling on lower tiers.

Supported networks

  • Mainnet — Chain ID: 56
  • Testnet — Chain ID: 97

See also

Parameters

0x-prefixed 32-byte block hash

0-based index

0x-prefixed 20-byte address

0x-prefixed 32-byte storage key hash

e.g. 1024

curl https://bsc.therpc.io/YOUR_API_KEY \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"debug_storageRangeAt","params":["0x0000000000000000000000000000000000000000000000000000000000000000",0,"","0x0000000000000000000000000000000000000000000000000000000000000000",10]}'

Ready to call this in production?

Free tier covers personal projects. Pay-as-you-go scales without a card.