slotSubscribe

slotSubscribe WebSocket Method

post

Subscribe to receive notification anytime a slot is processed by the validator. This method establishes a persistent WebSocket connection that will send real-time notifications whenever the validator processes a new slot. Each notification includes information about the current slot, its parent slot, and the current root slot. This subscription provides high-frequency updates about blockchain progression and is useful for monitoring network activity, tracking slot timing, and understanding the relationship between processed slots and finalized roots.

Authorizations
Body

Request object for subscribing to slot processing 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: slotSubscribePossible values:
Responses
101

WebSocket notification for slot processing

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

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

ws.onmessage = function(event) {
  const data = JSON.parse(event.data);
  
  if (data.method === 'slotNotification') {
    const { parent, root, slot } = data.params.result;
    const subscriptionId = data.params.subscription;
    
    console.log(`πŸ”— Slot ${slot} processed (parent: ${parent}, root: ${root})`);
    console.log(`   Subscription: ${subscriptionId}`);
    
    // Calculate slot progression
    const slotsFromRoot = slot - root;
    console.log(`   Slots since root: ${slotsFromRoot}`);
  } else if (data.result !== undefined) {
    console.log('Slot subscription ID:', data.result);
    console.log('Now monitoring slot progression in real-time...');
  }
};
{
  "jsonrpc": "2.0",
  "method": "slotNotification",
  "params": {
    "result": {
      "parent": 75,
      "root": 44,
      "slot": 76
    },
    "subscription": 0
  }
}

Last updated