I would like to obtain info particular smart contract - that is deployed on the RSK Testnet - to get the data values from its storage. How can I do this?
I'm using eth_getStorageAt
JSON-RPC, but i'm getting unexpected results.
To do this, you do indeed use the eth_getStorageAt
RPC request.
Here's an example:
curl \
-X POST \
-H "Content-Type:application/json" \
--data '{"jsonrpc":"2.0","method":"eth_getStorageAt","params":["0x19f64674d8a5b4e652319f5e239efd3bc969a1fe", "0x1", "latest"],"id":1}' \
https://public-node.testnet.rsk.co/
This will yield the following response
{
"jsonrpc": "2.0",
"id": 1, "result":"0x0000000000000000000000000000000000000000033b2e3c9fd0803ce8000000"
}
How it works - the eth_getStorageAt
RPC takes 3 params:
ADDRESS
- an address string of the smart contractSTORAGE_POSITION
- a hexadecimal string for the position in the storage of the smart contractBLOCK_PARAMETER
- a hexadecimal string of the integer block number for values at specific blocks, or the string latest
for the latest valueThe last parameter (BLOCK_PARAMETER
) is interesting, as you can use it to query historical values, and see how the data at that location within the storage changes over time, for example.