Skip to main content

rootUnsubscribe RPC Method

Loading...

Updated on
Apr 30, 2025

rootUnsubscribe RPC Method

Parameters

number
Loading...

Returns

result
boolean
Loading...
Request
1
import { createSolanaRpcSubscriptions } from '@solana/kit';
2
3
const rpcSubscriptions = createSolanaRpcSubscriptions('');
4
5
async function main() {
6
const abortController = new AbortController();
7
8
const subscription = await rpcSubscriptions
9
.rootNotifications()
10
.subscribe({ abortSignal: abortController.signal });
11
12
let counter = 0;
13
const maxCount = 3;
14
15
try {
16
for await (const notification of subscription) {
17
console.log("Updated root info: ", notification);
18
counter++;
19
20
if (counter >= maxCount) {
21
console.log(`Reached ${maxCount} notifications. Unsubscribing...`);
22
break;
23
}
24
}
25
} catch (e) {
26
console.error("Error in root subscription:", e);
27
} finally {
28
abortController.abort();
29
console.log('Unsubscribed from root changes');
30
}
31
}
32
33
main().catch(console.error);
Response
1
{
2
"jsonrpc": "2.0",
3
"result": true,
4
"id": 1
5
}
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free