Solana RPC · WebSocket subscriptions
WS accountSubscribe
Stream updates whenever an account changes.
Endpoint
WebSocket wss://solrpc.infinityblocks.io/<API_KEY>
Open the socket, then send a JSON-RPC accountSubscribe message. The server replies with a subscription id, then pushes notifications until you unsubscribe.
Parameters
| Param | Type | Required | Description |
|---|---|---|---|
address | string | yes | Base-58 account pubkey. |
config | object | no | encoding, commitment. |
Subscribe message
{"jsonrpc":"2.0","id":1,"method":"accountSubscribe","params":["<ADDRESS>",{"encoding":"base64","commitment":"confirmed"}]}
With @solana/web3.js
const id = rpc.onAccountChange(new PublicKey("<ADDRESS>"), (acc, ctx) => console.log(ctx.slot, acc.lamports));
Reply
{ "jsonrpc": "2.0", "id": 1, "result": 0 // subscription id }
Notification
{ "jsonrpc": "2.0", "method": "accountNotification",
"params": { "subscription": 0,
"result": { "context": { "slot": 423214981 },
"value": { "lamports": 12480000, "owner": "…", "data": ["","base64"], "executable": false } } } }
Try it
The interactive runner covers HTTP methods. WebSocket subscriptions use a persistent socket — use the subscribe message and the
@solana/web3.js example above.