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

ParamTypeRequiredDescription
filterstring|objectyes"all", "allWithVotes", or { "mentions": ["
"] }.
configobjectnocommitment.

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.