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

ParameterTypeRequiredDescription
account_includestring[]NoOnly include blocks that contain transactions involving these accounts
include_transactionsboolNoInclude full transaction data in the block (default: true)
include_accountsboolNoInclude account state changes in the block (default: false)
include_entriesboolNoInclude ledger entry data in the block (default: false)

Update Payload

FieldTypeDescription
slotuint64The block slot number
blockhashstringThe blockhash of this block
parent_slotuint64The parent block slot
parent_blockhashstringThe parent block hash
transactionsSubscribeUpdateTransactionInfo[]All transactions in the block (if include_transactions is true)
rewardsReward[]Validator and staking rewards
block_timeint64Estimated Unix timestamp of block production
block_heightuint64The block height
entriesSubscribeUpdateEntry[]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 CaseFilter Configuration
Full chain indexerinclude_transactions: true, include_accounts: true
Block explorerinclude_transactions: true, include_entries: true
DEX-focused indexeraccount_include: ["dexProgramId"], include_transactions: true
Reward trackerinclude_transactions: false (rewards always included)
Lightweight block feedinclude_transactions: false, include_accounts: false