slotsUpdatesSubscribe
Subscribe to receive a notification from the validator on a variety of updates on every slot
Common use cases
| Detect transaction expiration timing | Monitor slot updates to determine when a transaction's blockhash falls out of the status cache (typically 151 slots). Web3.js v2 uses this pattern to replace polling-based expiration detection with event-driven subscriptions, enabling faster, more resource-efficient transaction confirmation strategies. |
| Track slot lifecycle for fork detection | Subscribe to detailed slot state transitions including optimisticConfirmation, frozen, and dead events to detect blockchain forks and reorgs. The dead slot type indicates a slot that will not be part of the canonical chain, critical for applications requiring immediate fork awareness. |
| Monitor validator consensus progress | Track when slots transition from firstShredReceived through createdBank, frozen, optimisticConfirmation, and finally root to understand validator consensus timing and network health. Useful for validator monitoring dashboards and network analytics tools. |
Parameters
No parameters required.
Request
- wscat
- JavaScript
- Python
wscat -c wss://solana-mainnet.api.syndica.io -x '{
"jsonrpc": "2.0",
"id": 1,
"method": "slotsUpdatesSubscribe"
}'
const ws = new WebSocket('wss://solana-mainnet.api.syndica.io');
ws.on('open', function open() {
ws.send(JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "slotsUpdatesSubscribe"
}));
});
ws.on('message', function incoming(data) {
console.log(data);
});
import websocket
import json
ws = websocket.create_connection('wss://solana-mainnet.api.syndica.io')
ws.send(json.dumps({
"jsonrpc": "2.0",
"id": 1,
"method": "slotsUpdatesSubscribe"
}))
result = ws.recv()
print(result)
ws.close()
Replace mainnet with devnet in the URL to query devnet instead.
Response
{
"jsonrpc": "2.0",
"result": 0,
"id": 1
}
Response Fields
Return value: integer
Subscription id (needed to unsubscribe)
FAQ and Troubleshooting
Why does the official docs warn this subscription is "unstable"?
The notification format may change in future agave releases as slot lifecycle semantics evolve. Production applications should handle unknown update types gracefully and test compatibility when upgrading validators.
What's the difference between slotsUpdatesSubscribe and slotSubscribe?
slotSubscribe provides basic slot progression notifications (slot, parent, root). slotsUpdatesSubscribe provides detailed lifecycle events (firstShredReceived, completed, createdBank, frozen, dead, optimisticConfirmation, root) with additional metadata like transaction stats. Use slotSubscribe for simple progression monitoring, slotsUpdatesSubscribe when you need slot state transition visibility.
Which update types include transaction statistics?
Only the 'frozen' update type includes the stats object with transaction counts (successful, failed, entries, maxTransactionsPerEntry). Other update types do not include this field.
How do I detect when a transaction blockhash expires?
Monitor slot updates and track when the current slot exceeds your transaction's recent blockhash slot by more than 151 slots (the status cache size). Web3.js v2 implements this pattern in its confirmation strategies.
Do I need to filter specific update types on the client?
Yes. The subscription sends all update types. Client code should filter for relevant types (e.g., only 'root' for finality, only 'dead' for fork detection) to avoid processing unnecessary notifications.
Related Methods
slotsUpdatesUnsubscribe
Cancels the slotsUpdates subscription. Required to stop notifications and free server resources; always pair subscribe/unsubscribe for proper WebSocket lifecycle management.
slotSubscribe
Subscribe to basic slot progression notifications. Simpler alternative when detailed lifecycle events aren't needed; provides only slot, parent, and root fields without state transition granularity.
blockSubscribe
Subscribe to block notifications with full transaction data. Complementary to slotsUpdatesSubscribe; use slot updates to identify interesting slots, then subscribe to blocks for detailed content.
rootSubscribe
Subscribe to root (finalized) slot notifications. Can be combined with slotsUpdatesSubscribe to calculate finalization lag by comparing 'root' update types with rootSubscribe notifications.
External Resources
- Solana Official Documentation
- Solana Cookbook: Subscribing to Events - General WebSocket subscription patterns and best practices applicable to all subscription types