Overview
The block module provides Effect-wrapped utilities for fetching blockchain blocks. These are standalone functions that work withTransportService, useful for one-off block fetches without needing streaming helpers.
For continuous block streaming with reorg detection, use makeBlockStream.
Quick Start
Functions
fetchBlock
Fetch a block by number with optional transaction inclusion.blockNumber: bigint- Block number to fetchinclude: 'header' | 'transactions' | 'receipts'- Content levelretryOptions?: RetryOptions- Optional retry configuration
Effect<StreamBlock<TInclude>, BlockError, TransportService>
fetchBlockByHash
Fetch a block by its hash.blockHash: string- Block hash (hex string)include: 'header' | 'transactions' | 'receipts'- Content levelretryOptions?: RetryOptions- Optional retry configuration
Effect<StreamBlock<TInclude>, BlockError, TransportService>
fetchBlockReceipts
Fetch receipts for a block. Automatically falls back to individual receipt fetching ifeth_getBlockReceipts is not supported.
block: { hash: string; transactions?: Transaction[] }- Block object with hash and optional transactions
Effect<Receipt[], BlockError, TransportService>
toLightBlock
Convert a full block to a lightweight block for tracking (pure function, no Effect).LightBlock with number, hash, parentHash, and timestamp
Types
BlockInclude
Content level for block fetching:LightBlock
Minimal block info for reorg tracking:RetryOptions
Retry configuration for RPC calls:Error Handling
All functions returnBlockError in the error channel:
BlockNotFoundError- Block doesn’t existBlockStreamAbortedError- Operation was cancelledBlockRangeTooLargeError- RPC rejected range as too large
Layer Composition
Works with any TransportService implementation:Comparison with makeBlockStream
| Feature | Block module | makeBlockStream |
|---|---|---|
| One-off fetches | ✅ Ideal | Overkill |
| Continuous streaming | ❌ Manual | ✅ Built-in |
| Reorg detection | ❌ Manual | ✅ Automatic |
| Backfill | ❌ Loop manually | ✅ backfill() |
| Watch mode | ❌ Not supported | ✅ watch() |
See Also
- Block Streaming — Continuous block streaming with reorg detection
- Block Streaming Example — Complete streaming examples
- Provider Service —
getBlockmethod for one-off fetches - Stream Errors — Error types for streaming operations
- Voltaire Block — Core block documentation

