Overview
BlockFilter represents a filter created by eth_newBlockFilter that notifies of new block hashes. Used for monitoring blockchain progress and detecting reorgs without polling full blocks.
Type Definition
Creating BlockFilter
from
filterId:FilterIdType- Filter identifier frometh_newBlockFilter
BlockFilterType
JSON-RPC Usage
Create Filter
Poll for Changes
Uninstall Filter
Example: Block Monitor
Example: Reorg Detector
Comparison with eth_subscribe
BlockFilter (eth_newBlockFilter)
Pros:- HTTP compatible (no WebSocket required)
- Simple request-response pattern
- Works with all RPC providers
- Polling-based (less efficient)
- Delayed notifications (poll interval)
- Filter expiration if not polled
eth_subscribe
Pros:- Real-time push notifications
- More efficient (no polling)
- No filter expiration
- Requires WebSocket connection
- Not supported by all providers
- More complex error handling
Filter Expiration
Block filters expire after inactivity (typically 5 minutes). Best practices:Performance Considerations
Polling Frequency
Choose poll interval based on:- Block time (12s for Ethereum mainnet)
- Filter expiration timeout
- Application latency requirements
Batch Processing
Process multiple blocks efficiently:Use Cases
Block Height Tracker
Transaction Confirmation Monitor
Network Activity Monitor
Related Types
- FilterId - Filter identifier
- LogFilter - Event log filter
- PendingTransactionFilter - Pending tx filter
- BlockHash - Block hash type
- BlockNumber - Block number type
JSON-RPC Methods
eth_newBlockFilter- Create block hash filtereth_getFilterChanges- Poll for new blockseth_uninstallFilter- Remove filtereth_getBlockByHash- Fetch full block

