Skip to content

@thru/replay

View as Markdown

@thru/replay turns chain RPC backfill plus live streaming into a single ordered feed.

Terminal window
npm install @thru/replay @thru/sdk

Choose this package when you need a durable ordered feed for analytics, ETL, or event processing and want to decide where the data lands yourself.

Choose a different package when:

  • you need persistence, checkpoints, and Drizzle-backed stream definitions on top of the feed: use @thru/indexer
  • you need a full app-facing RPC SDK instead of replay primitives: use @thru/sdk

The package is root-only. Import what you need from @thru/replay; there are no public subpath exports.

ExportUse it for
ChainClientConnecting to Thru query and streaming services with one client wrapper.
createBlockReplayOrdered block replay with optional filters, consensus floor, and block view settings.
createTransactionReplayOrdered transaction replay, including optional event payloads.
createEventReplayOrdered event replay with reconnect support.
createAccountReplayReplaying one account’s state over time.
createAccountsByOwnerReplayReplaying all accounts owned by a program with backfill plus live updates.
ReplayStreamThe async iterator that merges backfill and live data into one ordered stream.
PageAssemblerReassembling multi-page account updates into complete account payloads.
ReplaySink and ConsoleSinkWriting replay output to a sink implementation or the console.
createConsoleLogger and NOOP_LOGGERStructured logging for replay runs.
  • Use createBlockReplay, createTransactionReplay, or createEventReplay when you want a typed ordered feed for analytics, ETL, or event processing.
  • Use createAccountsByOwnerReplay when you need to index all accounts owned by a program and keep them current.
  • Use ReplayStream directly when you already have your own backfill fetcher and live subscriber.
  • Use PageAssembler when you need to assemble multi-page account updates into complete payloads before processing them.

Account replay is split into two shapes:

  • createAccountReplay for one account address.
  • createAccountsByOwnerReplay for owner-scoped indexing with backfill, live updates, and reconnect handling.

The replay package depends on generated protobuf types from @thru/sdk/proto internally.

Replay items are ordered by slot, deduplicated across the backfill/live overlap window, and exposed through an AsyncIterable. ReplaySinkContext tags each item with the replay phase, backfill or live, so downstream code can treat historical and realtime data differently if needed.

import { ChainClient, createBlockReplay } from "@thru/replay";
const client = new ChainClient({ baseUrl: process.env.CHAIN_RPC_URL! });
const replay = createBlockReplay({ client, startSlot: 1_000_000n });
for await (const block of replay) {
console.log(block.header?.slot?.toString());
}