slotsUpdatesSubscribe | Solana

The slotsUpdatesSubscribe method in Solana allows developers to receive real-time notifications about slot updates including timing information. This subscription-based method provides more detailed updates about slot processing compared to slotSubscribe.

Parameters

None. This method does not accept any parameters.

Response

  • result - An integer subscription id (needed to unsubscribe)
  • subscription - An object containing detailed slot information:
    • slot - The current slot height
    • timestamp - The current estimated production time (as Unix timestamp) of the slot
    • type - The type of slot update:
      • "firstShredReceived" - The first shred of the slot was received
      • "completed" - The slot was completed
      • "createdBank" - The bank for the slot was created
      • "frozen" - The bank for the slot was frozen
      • "dead" - The bank for the slot was marked as dead
      • "optimisticConfirmation" - The slot was optimistically confirmed
      • "root" - The slot was rooted

slotsUpdatesSubscribe code examples

This example subscribes to detailed slot updates.

📘

Note that subscriptions require a WebSocket connection and WebSocket cat for you to use this method in the console.

Install WebSocket cat with:

npm install -g wscat

$ wscat -c YOUR_CHAINSTACK_WEBSOCKET_ENDPOINT
# Wait for the connection to be established

Connected (press CTRL+C to quit)

> {"jsonrpc":"2.0","id":1,"method":"slotsUpdatesSubscribe"}

Use case

The slotsUpdatesSubscribe method is valuable for applications that need detailed monitoring of the Solana blockchain's slot processing. Common use cases include:

  • Performance monitoring: Track detailed slot processing times and states
  • Debugging: Monitor slot processing stages for troubleshooting
  • Chain health monitoring: Track slot completion and confirmation rates
  • Analytics: Gather detailed metrics about blockchain performance
  • Advanced timing: Coordinate operations based on specific slot states

By subscribing to detailed slot updates, applications can gain deeper insights into the blockchain's operation and implement more sophisticated timing and monitoring systems.