Overview
FilterId is a branded string type representing an opaque filter identifier returned by JSON-RPC filter creation methods (eth_newFilter, eth_newBlockFilter, eth_newPendingTransactionFilter). Filter IDs are used to poll for updates and uninstall filters.
Type Definition
Creating FilterId
From Hex / Bytes
FilterId from a string value. The string is typically a hex-encoded number returned by the node.
Parameters:
value:string- Filter ID string
FilterIdType
Throws: InvalidFilterIdError if value is not a string or is empty
Operations
Serialize for JSON
FilterId back to its string representation.
equals
FilterId instances for equality.
JSON-RPC Filter Lifecycle
Filters follow a request-response lifecycle on Ethereum nodes:1. Create Filter
2. Poll for Changes
3. Get All Logs (log filters only)
4. Uninstall Filter
Filter Expiration
Filters automatically expire after a period of inactivity (typically 5 minutes). Nodes may:- Return empty arrays for expired filters
- Return errors for invalid filter IDs
- Silently drop old filters during node restarts
- Poll filters regularly to prevent expiration
- Handle
filter not founderrors gracefully - Recreate filters after node restarts
Example: Complete Filter Workflow
Related Types
- LogFilter - Log/event filter parameters
- BlockFilter - Block hash filter
- PendingTransactionFilter - Pending transaction filter
- TopicFilter - Event topic matching
JSON-RPC Methods
eth_newFilter- Create log filter, returns FilterIdeth_newBlockFilter- Create block filter, returns FilterIdeth_newPendingTransactionFilter- Create pending tx filter, returns FilterIdeth_getFilterChanges- Poll for new results since last calleth_getFilterLogs- Get all logs for log filtereth_uninstallFilter- Remove filter from node

