> For the complete documentation index, see [llms.txt](https://fifo-docs.gitbook.io/colibri/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fifo-docs.gitbook.io/colibri/colibri-rpc-streamer/ledgers.md).

# Stream ledgers

Choose ledger streaming to inspect the transactions and operations in a ledger, rather than only matching events. The handler receives Core's lazy [`Ledger`](/colibri/colibri-core/ledger-parser.md).

Install the packages from the [overview](/colibri/colibri-rpc-streamer/rpc-streamer.md), save this as `ledgers.ts`, and run `deno run --allow-net ledgers.ts`.

```ts
import { NetworkConfig } from "@colibri/core";
import { RPCStreamer } from "@colibri/rpc-streamer";

const streamer = RPCStreamer.ledger({
  networkConfig: NetworkConfig.TestNet(),
});
const { latestLedger } = await streamer.rpc.getHealth();
await streamer.startLive(async (ledger) => {
  console.log(`Ledger ${ledger.sequence}: ${ledger.hash}`);
  console.log(`${ledger.transactions.length} transactions`);
}, { startLedger: latestLedger, stopLedger: latestLedger });
```

This is a bounded read; it does not submit a transaction. The built-in ledger ingestors fetch one ledger per request. Increasing `limit` does not turn the ledger variant into a batch ingestor.

## Network identity

Ledger, transaction and operation streams use the supplied [`NetworkConfig`](/colibri/colibri-core/network.md) passphrase. With a URL or native RPC client, they discover it through `getNetwork()` and cache successful discovery per RPC connection. Live and archive clients must serve the intended network. Discovery failures retain their cause and are not cached as successful results.

This context lets Core associate envelopes with execution results by hash instead of assuming transaction-set order is execution order. It does not change the stream's checkpoint, cancellation or failed-transaction policy.

## Parsing only what you need

Core defers decoding until a property needs it and memoizes parsed results. You do not have to parse every operation just to display a ledger sequence. See the [ledger parser](/colibri/colibri-core/ledger-parser.md) for deeper inspection.

## Long-lived consumers

Omit `stopLedger` to continue. Store your own last successfully processed ledger after awaited application work. `stop()` requests a stop but does not abort an in-flight RPC request. Await the streaming promise before shutting down resources used by your callback. See [progress and recovery](/colibri/colibri-rpc-streamer/recovery.md).
