gRPC Subscription Filters
The Subscribe method accepts filters for different data types. Each filter streams specific on-chain data in real-time directly from the Solana validator with sub-millisecond latency.
Available Subscriptions
| Subscription | Description | Common Use Case |
|---|---|---|
| Accounts | Real-time account state changes | Token balances, program state, wallet monitoring |
| Transactions | Individual transactions as processed | DEX trade monitoring, copy trading, MEV |
| TransactionStatus | Transaction confirmation status | Confirmation tracking without full tx data |
| Blocks | Complete block data with transactions | Block explorers, full indexing |
| BlockMeta | Block metadata without transaction details | Slot monitoring, block timing |
| Slots | Slot progression notifications | Leader tracking, timing synchronization |
| Entries | Ledger entry data | Advanced analytics, validator monitoring |
| Programs | Program deployment and upgrade events | Protocol monitoring, security alerts |
How Subscriptions Work
All subscriptions are multiplexed through a single bidirectional gRPC stream opened by the Subscribe method. You can combine multiple subscription types in a single request — for example, monitoring specific accounts while also tracking slot progression.
Each subscription filter has a label (the key in the map). When an update matches your filter, the response includes which labels matched, so you can route updates to the correct handler.
Quick Example
1const stream = client.subscribe(new grpc.Metadata());
2
3stream.on('data', (update) => {
4 if (update.account) {
5 console.log('Account update:', Buffer.from(update.account.account.pubkey).toString('hex'));
6 } else if (update.transaction) {
7 console.log('Transaction:', Buffer.from(update.transaction.transaction.signature).toString('hex'));
8 } else if (update.slot) {
9 console.log('Slot:', update.slot.slot, 'Status:', update.slot.status);
10 }
11});
12
13// Subscribe to Raydium accounts + all slots
14stream.write({
15 accounts: {
16 raydium: {
17 account: [],
18 owner: ['675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8'],
19 filters: []
20 }
21 },
22 slots: { allSlots: {} },
23 transactions: {},
24 blocks: {},
25 blocksMeta: {},
26 commitment: 1,
27 entry: {},
28 accountsDataSlice: [],
29 ping: null
30});Commitment Levels
| Value | Level | Latency | Recommendation |
|---|---|---|---|
0 | Processed | Lowest | HFT bots, snipers, real-time UIs |
1 | Confirmed | Medium | Most applications |
2 | Finalized | Highest | Exchanges, settlement systems |