Skip to main content

accountSubscribe RPC Method

Loading...

Updated on
Apr 30, 2025

accountSubscribe RPC Method

Parameters

Pubkey
string
Loading...
object
object
Loading...
commitment
string
Loading...
encoding
string
Loading...

Returns

result
integer
Loading...
Notification Format:
Loading...
Request
1
import { address, createSolanaRpcSubscriptions } from '@solana/kit';
2
3
const rpcSubscriptions = createSolanaRpcSubscriptions('');
4
5
async function main() {
6
const abortController = new AbortController();
7
const accountNotifications = await rpcSubscriptions
8
.accountNotifications(address('9kwU8PYhsmRfgS3nwnzT3TvnDeuvdbMAXqWsri2X8rAU'), { commitment: 'confirmed' })
9
.subscribe({ abortSignal: abortController.signal });
10
11
try {
12
for await (const notification of accountNotifications) {
13
console.log('New balance', notification.value.lamports);
14
}
15
} catch (e) {
16
console.error(e);
17
}
18
19
}
20
21
main();
Response
1
{
2
"jsonrpc": "2.0",
3
"result": 23784,
4
"id": 1
5
}
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free