Block Subscriptions
Stream complete blocks as they are produced by the validator, including all transactions, account state changes, rewards, and ledger entries. This is the most data-rich subscription type, delivering everything you would get from calling GetBlock on every slot -- but pushed to you in real time.
Block subscriptions are essential for building block explorers, full-chain indexers, and analytics pipelines. You can optionally include or exclude transactions, accounts, and entries to control bandwidth. For lightweight monitoring where you only need block metadata, use BlockMeta Subscriptions instead.
Filter Parameters
| Parameter | Type | Required | Description |
|---|
account_include | string[] | No | Only include blocks that contain transactions involving these accounts |
include_transactions | bool | No | Include full transaction data in the block (default: true) |
include_accounts | bool | No | Include account state changes in the block (default: false) |
include_entries | bool | No | Include ledger entry data in the block (default: false) |
Update Payload
| Field | Type | Description |
|---|
slot | uint64 | The block slot number |
blockhash | string | The blockhash of this block |
parent_slot | uint64 | The parent block slot |
parent_blockhash | string | The parent block hash |
transactions | SubscribeUpdateTransactionInfo[] | All transactions in the block (if include_transactions is true) |
rewards | Reward[] | Validator and staking rewards |
block_time | int64 | Estimated Unix timestamp of block production |
block_height | uint64 | The block height |
entries | SubscribeUpdateEntry[] | Ledger entries (if include_entries is true) |
Code Examples
Stream Full Blocks (Node.js)
1stream.write({
2 accounts: {},
3 slots: {},
4 transactions: {},
5 transactionsStatus: {},
6 blocks: {
7 fullBlocks: {
8 account_include: [],
9 include_transactions: true,
10 include_accounts: false,
11 include_entries: false
12 }
13 },
14 blocksMeta: {},
15 commitment: 1,
16 entry: {},
17 accountsDataSlice: [],
18 ping: null
19});
20
21stream.on('data', (update) => {
22 if (update.block) {
23 const block = update.block;
24 console.log('Slot:', block.slot);
25 console.log('Blockhash:', block.blockhash);
26 console.log('Block height:', block.block_height);
27 console.log('Transactions:', block.transactions.length);
28 console.log('Block time:', new Date(block.block_time * 1000).toISOString());
29 console.log('Rewards:', block.rewards.length);
30 }
31});
Stream and Index Blocks (Rust)
1use yellowstone_grpc_client::GeyserGrpcClient;
2use yellowstone_grpc_proto::prelude::*;
3use std::collections::HashMap;
4use futures::StreamExt;
5
6#[tokio::main]
7async fn main() -> anyhow::Result<()> {
8 let mut client = GeyserGrpcClient::build_from_uri("http://[IP_ADDRESS]:[PORT]")
9 .connect()
10 .await?;
11
12 let mut blocks = HashMap::new();
13 blocks.insert("allBlocks".to_string(), SubscribeRequestFilterBlocks {
14 account_include: vec![],
15 include_transactions: Some(true),
16 include_accounts: Some(false),
17 include_entries: Some(false),
18 });
19
20 let request = SubscribeRequest {
21 accounts: HashMap::new(),
22 slots: HashMap::new(),
23 transactions: HashMap::new(),
24 transactions_status: HashMap::new(),
25 blocks,
26 blocks_meta: HashMap::new(),
27 commitment: Some(CommitmentLevel::Confirmed as i32),
28 entry: HashMap::new(),
29 accounts_data_slice: vec![],
30 ping: None,
31 from_slot: None,
32 };
33
34 let (_, mut stream) = client.subscribe_with_request(Some(request)).await?;
35
36 while let Some(msg) = stream.next().await {
37 match msg?.update_oneof {
38 Some(UpdateOneof::Block(block)) => {
39 println!("Block slot: {} | hash: {} | txns: {} | height: {}",
40 block.slot,
41 block.blockhash,
42 block.transactions.len(),
43 block.block_height.unwrap_or_default());
44 }
45 _ => {}
46 }
47 }
48
49 Ok(())
50}
Common Use Cases
| Use Case | Filter Configuration |
|---|
| Full chain indexer | include_transactions: true, include_accounts: true |
| Block explorer | include_transactions: true, include_entries: true |
| DEX-focused indexer | account_include: ["dexProgramId"], include_transactions: true |
| Reward tracker | include_transactions: false (rewards always included) |
| Lightweight block feed | include_transactions: false, include_accounts: false |