starknet_getStorageProof
Get merkle paths in one of the state tries: global state, classes, individual contract. A single request can query for any mix of the three types of storage proofs (classes, contracts, and storage).
Parameters
Parameter | Type | Description |
---|---|---|
block_id | string | Block reference ("latest", "l1_accepted", block hash, or block number) |
class_hashes | felt252[] | Array of class hashes (optional) |
contract_addresses | felt252[] | Array of contract addresses (optional) |
contracts_storage_keys | array | Array of contract-storage key pairs (optional) |
Request
{
"jsonrpc": "2.0",
"method": "starknet_getStorageProof",
"params": [
{
"block_hash": "0x05abbad1e5"
},
[
"0x05abbad1e5"
],
[
"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
],
[
{
"contract_address": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"storage_keys": [
"0x1"
]
}
]
],
"id": 1
}
Returns
The requested storage proofs. Note that if a requested leaf has the default value, the path to it may end in an edge node whose path is not a prefix of the requested leaf, thus effectively proving non-membership
Storage proof object with classes proof, contracts proof, storage proofs, and global roots
Errors
Code | Message |
---|---|
24 | Block not found |
42 | the node doesn't support storage proofs for blocks that are too far in the past |
Examples
- cURL
- JavaScript
curl -X POST https://api-starknet-mainnet.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "starknet_getStorageProof",
"params": [
{
"block_hash": "0x05abbad1e5"
},
[
"0x05abbad1e5"
],
[
"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
],
[
{
"contract_address": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"storage_keys": [
"0x1"
]
}
]
],
"id": 1
}'
import { RpcProvider } from 'starknet';
const provider = new RpcProvider({
nodeUrl: 'https://api-starknet-mainnet.n.dwellir.com/YOUR_API_KEY',
});
const payload = {
method: 'starknet_getStorageProof',
params: [
{
"block_hash": "0x05abbad1e5"
},
[
"0x05abbad1e5"
],
[
"0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
],
[
{
"contract_address": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"storage_keys": [
"0x1"
]
}
]
]
};
const result = await provider.fetchEndpoint(payload.method, payload.params);
console.log(result);