The rootSubscribe
method in Solana allows developers to receive real-time notifications about changes to the root of the ledger. This subscription-based method provides updates whenever a new root is set.
<commitment>
- (optional) The level of commitment desired when querying state. Default is “finalized”.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 examplesnpm 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": "rootSubscribe" }
rootSubscribe
method is particularly useful for applications that need to monitor the finality of the Solana blockchain. Common use cases include:
Was this page helpful?