Solana RPC · WebSocket subscriptions
WS logsSubscribe
Stream transaction logs, optionally filtered by account.
Endpoint
WebSocket wss://solrpc.infinityblocks.io/<API_KEY>
Open the socket, then send a JSON-RPC logsSubscribe message. The server replies with a subscription id, then pushes notifications until you unsubscribe.
Parameters
| Param | Type | Required | Description |
|---|---|---|---|
filter | string|object | yes | "all", "allWithVotes", or { "mentions": [""] }. |
config | object | no | commitment. |
Subscribe message
{"jsonrpc":"2.0","id":1,"method":"logsSubscribe","params":[{"mentions":["<PROGRAM_ID>"]},{"commitment":"confirmed"}]}
With @solana/web3.js
rpc.onLogs(new PublicKey("<PROGRAM_ID>"), (l) => console.log(l.signature, l.logs));
Reply
{ "jsonrpc": "2.0", "id": 1, "result": 0 // subscription id }
Notification
{ "jsonrpc": "2.0", "method": "logsNotification",
"params": { "subscription": 0,
"result": { "context": { "slot": 423214981 },
"value": { "signature": "<SIGNATURE>", "err": null, "logs": ["Program … invoke [1]","Program … success"] } } } }
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.