slotSubscribe
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.
Request object for subscribing to slot processing notifications via WebSocket
JSON-RPC protocol version
2.0
Possible values: Request identifier that will be returned in the response
1
The WebSocket method name
slotSubscribe
Possible values: WebSocket notification for slot processing
Subscription successfully created
Bad Request - Invalid parameters
Unauthorized
Forbidden
Too Many Requests
Internal Server Error
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