state_subscribeStorage - Avail

Opens a subscription that streams change sets whenever any of the given storage keys change. WebSocket only. Passing an empty key list subscribes to all storage changes (heavy).

This is a WebSocket-only subscription. Connect over wss:// and unsubscribe with state_unsubscribeStorage.

Parameters

ParameterTypeRequiredDescription
keysarrayYesArray of hex storage keys to watch

Subscribe

bashwscat -c wss://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/

# then send:
{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "method": "state_subscribeStorage",
    "params": [
        [
            "0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9"
        ]
    ]
}

Subscription ID

The initial response returns the subscription id used to correlate and cancel the stream:

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "Ce9D...e1"
}

Notifications

While subscribed, the node pushes a notification per update:

json{
    "jsonrpc": "2.0",
    "method": "state_Storage_notification",
    "params": {
        "subscription": "Ce9D...e1",
        "result": {
            "block": "0x8a1e6d2f0b7c4a9e3d5f1b8c2a6e4d0f9b3c7a5e1d8f2b6c4a0e9d3f7b1c5a2e6",
            "changes": [
                [
                    "0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9",
                    "0x03000000..."
                ]
            ]
        }
    }
}

Notification Fields

FieldTypeDescription
blockstringBlock at which the change occurred
changesarrayArray of [key, value] change pairs; value null if cleared

Use Cases

  • Balance Watching: React to account balance changes
  • Live State: Keep a cache in sync with on-chain storage
  • Event-Driven UIs: Update views on state changes

Error Handling

ErrorMessageDescription
-32603 / Internal errorSubscription errorThe subscription could not be established
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect