rootSubscribe

rootSubscribe WebSocket Method

post

Subscribe to receive notification anytime a new root is set by the validator. This method establishes a persistent WebSocket connection that will send real-time notifications whenever the validator updates the root slot. The root represents the most recent slot that has been finalized and committed to the ledger. This subscription is useful for tracking the overall progress of the blockchain and understanding when transactions become irreversibly confirmed.

Authorizations
Body

Request object for subscribing to root change notifications via WebSocket

jsonrpcstring Β· enumRequired

JSON-RPC protocol version

Example: 2.0Possible values:
idone ofRequired

Request identifier that will be returned in the response

Example: 1
stringOptional
or
numberOptional
methodstring Β· enumRequired

The WebSocket method name

Example: rootSubscribePossible values:
Responses
101

WebSocket notification for root changes

application/json
post
const ws = new WebSocket('wss://public.rpc.solanavibestation.com');

ws.onopen = function() {
  // Subscribe to root notifications
  ws.send(JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'rootSubscribe'
  }));
};

ws.onmessage = function(event) {
  const data = JSON.parse(event.data);
  
  if (data.method === 'rootNotification') {
    const rootSlot = data.params.result;
    const subscriptionId = data.params.subscription;
    console.log(`New root set at slot ${rootSlot} (subscription: ${subscriptionId})`);
  } else if (data.result !== undefined) {
    console.log('Root subscription ID:', data.result);
  }
};
{
  "jsonrpc": "2.0",
  "method": "rootNotification",
  "params": {
    "result": 42,
    "subscription": 0
  }
}

Last updated