Parameters
<commitment>- (optional) The level of commitment desired when querying state. Default is “finalized”.
Response
-
result- An integer subscription id (needed to unsubscribe) -
subscription- An object containing root information:root- The slot number that has been rootedtimestamp- The estimated production time of the rooted slot, as Unix timestamp (seconds since the Unix epoch)
rootSubscribe code examples
This example subscribes to root 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 wscatUse case
TherootSubscribe method is particularly useful for applications that need to monitor the finality of the Solana blockchain. Common use cases include:
- Finality tracking: Monitor when slots become rooted (finalized) in the blockchain
- Chain reorganization detection: Track changes in the root to detect potential chain reorganizations
- Historical data processing: Know when slots are safe to process for historical data analysis
- Consensus monitoring: Track the progress and health of consensus by monitoring root advancement