@thru/replay turns chain RPC backfill plus live streaming into a single ordered feed.
Install
When to use it
Choose this package when you only need a durable ordered feed for analytics, ETL, or event processing. Use@thru/indexer when you also want to store the data, checkpoint progress, or mount read routes.
Choose a different package when:
- You need persistence, checkpoints, and read APIs on top of the feed: use
@thru/indexer - You need a full app-facing RPC SDK instead of replay primitives: use
@thru/thru-sdk
Entry point
The package is root-only. Import what you need from@thru/replay; there are no subpath exports.
Main exports
| Export | Use it for |
|---|---|
ChainClient | Connecting to the Thru query and streaming services with one client wrapper. |
createBlockReplay | Ordered block replay with optional filters, consensus floor, and block view settings. |
createTransactionReplay | Ordered transaction replay, including optional event payloads. |
createEventReplay | Ordered event replay with reconnect support. |
createAccountReplay | Replaying one account’s state over time. |
createAccountsByOwnerReplay | Replaying all accounts owned by a program with backfill plus live updates. |
ReplayStream | The async iterator that merges backfill and live data into one ordered stream. |
PageAssembler | Reassembling multi-page account updates into complete account payloads. |
ReplaySink and ConsoleSink | Writing replay output to a sink implementation or the console. |
createConsoleLogger and NOOP_LOGGER | Structured logging for replay runs. |
DEFAULT_RETRY_CONFIG, calculateBackoff, withTimeout, delay, TimeoutError | Retry and timeout helpers for live reconnect behavior. |
Common workflows
- Use
createBlockReplay,createTransactionReplay, orcreateEventReplaywhen you want a typed ordered feed for analytics, ETL, or event processing. - Use
createAccountsByOwnerReplaywhen you need to index all accounts owned by a program and keep them current. - Use
ReplayStreamdirectly when you already have your own backfill fetcher and live subscriber. - Use
PageAssemblerwhen you need to assemble multi-page account updates into complete payloads before processing them.
Account replay
Account replay is split into two shapes:createAccountReplayfor one account address.createAccountsByOwnerReplayfor owner-scoped indexing with backfill, live updates, and reconnect handling.
AccountView, ListAccounts, GetAccount, and StreamAccountUpdates types from @thru/proto.
Data model
Replay items are ordered by slot, deduplicated across the backfill/live overlap window, and exposed through anAsyncIterable.
ReplaySinkContext tags each item with the replay phase, backfill or live, so downstream code can treat historical and realtime data differently if needed.
Minimal example
Related guides
- Indexing Overview for package selection and the full indexing guide structure.
- Build an Indexer for a step-by-step guide using
@thru/indexeron top of replay. @thru/indexerfor the persistence, checkpoint, and API layer built on replay.- Web SDKs Overview for the full list of web packages.