debug_storageRangeAt - Ethereum
The debug_storageRangeAt method is part of the Ethereum JSON RPC Core API, used for debugging purposes. It allows developers to retrieve contract storage data within a specified range.
Remix uses debug_storageRangeAt to implement debugging. Use the Debuggertab in Remix instead of calling debug_storageRangeAt directly.Returns the contract storage for the specified range.
The debug_storageRangeAt method is part of the Ethereum JSON RPC Core API, designed for debugging purposes. This method allows developers to retrieve contract storage data within a specified range. While primarily used by tools like Remix, developers can call it directly to inspect and analyze on-chain storage data.
Supported Networks
The debug_storageRangeAt RPC Ethereum method supports all Ethereum network types, including:
Mainnet
Testnets: Sepolia, Holesky
Parameters
The debug_storageRangeAt method accepts the following parameters:
blockHash: (data) The block hash to fetch storage from.
txIndex: (integer) Transaction index within the block to start from.
address: (data) Contract address whose storage is to be retrieved.
startKey: (hash) The starting key for the storage range.
limit: (integer) Number of storage entries to return.
Request Example
URL (API Endpoints) https://go.getblock.io/<ACCESS-TOKEN>/
To make a request, send a JSON object with the jsonrpc, method, and params fields. Below is an example of how to make a request using curl:
Response Example
The server responds with a JSON object. Below is an example response for the debug_storageRangeAt method:
Response Description
result: Contains the contract storage data for the specified range, or null if unavailable.
status_code: The HTTP status code for the request.
message: An explanatory message, e.g., "Method not allowed."
storage: An object containing key-value pairs of the storage.
hash: The hash value of the storage entry.
key: The storage key associated with the hash.
value: The storage value associated with the hash.
nextKey: The hash of the next key if additional storage entries are present within the range. Otherwise, not included.
Use Case
The debug_storageRangeAt method is invaluable for debugging smart contracts by allowing developers to inspect storage within a specified range. This is particularly useful when analyzing contract behavior or diagnosing issues related to on-chain storage. If a debug_storageRangeAt error occurs, ensure that the parameters, such as blockHash and address, are correct. The provided debug_storageRangeAt example demonstrates how to construct a proper request.
Example Code
You can make requests to the debug_storageRangeAt method programmatically using Python. Below is an example using the requests library:
This script sends a request to the debug_storageRangeAt method and prints the result. Replace <ACCESS-TOKEN> with your actual API token. The Web3 debug_storageRangeAt method can also be used through Web3 libraries for Ethereum.
The Ethereum debug_storageRangeAt method provides structured insights into contract storage. As part of the Core API Endpoints, it ensures developers have access to essential debugging tools. Each storage entry includes its key, value, and optional nextKey for further exploration. By supporting detailed storage data retrieval, this method integrates seamlessly with Ethereum's JSON RPC API for advanced debugging capabilities.
\
Last updated