Solana RPC · WebSocket subscriptions
WS slotSubscribe
Stream a notification on every new slot.
Endpoint
WebSocket wss://solrpc.infinityblocks.io/<API_KEY>
Open the socket, then send a JSON-RPC slotSubscribe message. The server replies with a subscription id, then pushes notifications until you unsubscribe.
Parameters
This method takes no parameters.
Subscribe message
{"jsonrpc":"2.0","id":1,"method":"slotSubscribe"}
With @solana/web3.js
rpc.onSlotChange((s) => console.log(s.slot));
Reply
{ "jsonrpc": "2.0", "id": 1, "result": 0 // subscription id }
Notification
{ "jsonrpc": "2.0", "method": "slotNotification",
"params": { "subscription": 0, "result": { "parent": 423214980, "root": 423214949, "slot": 423214981 } } }
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.