state_subscribeStorage - Bittensor
Example code for the state_subscribeStorage JSON-RPC method. Complete guide on how to use state_subscribeStorage JSON-RPC in GetBlock Web3 documentation.
Subscribes to changes at given storage keys. Returns a subscription ID; updates arrive as separate WebSocket messages with method state_storage. Pass an array of keys to watch multiple slots in a single subscription.
Parameters
keys
array of string
Yes
Array of hex-encoded storage keys to watch
Request Example
# WebSocket-only method. Use wscat (or similar) to connect first:
wscat -c 'wss://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/'
# Then send:
{"jsonrpc": "2.0", "method": "state_subscribeStorage", "params": [["0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9"]], "id": "getblock.io"}import WebSocket from 'ws';
const ws = new WebSocket('wss://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/');
ws.on('open', () => {
ws.send(JSON.stringify({
"jsonrpc": "2.0",
"method": "state_subscribeStorage",
"params": [
[
"0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9"
]
],
"id": "getblock.io"
}));
});
ws.on('message', (data) => {
console.log(JSON.parse(data.toString()));
});Response Example
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": "F4dG5hI6jK7lM8nO9pQ0r"
}Response Parameters
result
string
Subscription ID for storage change notifications
Use Cases
Real-time tracking of account balances or specific storage slots
Reactive UIs that update on chain state changes
Subnet/neuron monitoring (subscribe to specific neuron storage slots)
Error Handling
403
Forbidden
Missing or invalid <ACCESS-TOKEN>
-32602
Invalid params
Request parameters are missing or malformed
-32601
Method not found
Method does not exist on this interface — check whether you're calling a Substrate method on an EVM endpoint or vice versa
-32603
Internal error
Server-side error while processing the request
429
Too Many Requests
Rate limit exceeded for your plan
SDK Integration
Last updated
Was this helpful?