Add `stellar ledger meta fetch` subcommand to download ledger close meta

Open
#2,418 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
cli

Research direction

Start by reading the existing stellar snapshot create and stellar ledger fetch commands, then consult SEP-54 for datastore layout and LedgerCloseMeta formats. Done means stellar ledger meta fetch handles a ledger or range, downloads over HTTP, supports xdr/json/json-formatted output, and reassembles requested ranges into one batch.

Written by the indexing model from the issue text.

Description

feature request
What problem does your feature solve?

There's no easy way to fetch ledger close meta from a network's ledger meta datastore. I have built one-off throw-away tools for this and I noticed @stellar/platform-eng discussing that they'd like a tool for this type of thing too (ref), although they may still build something else that collects the data directly from a stellar-core which isn't what this issue proposes, but regardless there's some evidence at least in my own workflows this would be a useful capability, and should be a very lightweight lift, because we are mostly talking about just downloading a file.

I have considered opening this issue in the past but struggled to imagine where in the cli such a command would fit. The recently added stellar ledger subcommand provides a natural home for this.

What would you like to see?

A new stellar ledger meta fetch subcommand that downloads LedgerCloseMetaBatch from a network's ledger meta datastore (as specified in SEP-54) for a specific ledger or a range of ledgers.

Usage:

# Single ledger
stellar ledger meta fetch --ledger 1000

# Range of ledgers
stellar ledger meta fetch --start 1000 --end 2000

--ledger is mutually exclusive with --start/--end.

Key details:

  • Output type:
    • Return a LedgerCloseMeta when --ledger is used.
    • Return a LedgerCloseMetaBatch when --start and --end are used.
    • Using different types may be a little confusing, but I think the common case looking at my own past usages was to get a single ledgers worth, and in that case it is more convenient to have it as just the LedgerCloseMeta.
  • Output format: Support --output with values xdr, json, and json-formatted (consistent with other CLI commands).
  • Datastore access: The command should download the datastore config, then fetch the required batches over plain HTTP (no S3 SDK). This is important because not all datastores are S3-backed — e.g. Galexie in Quickstart serves over HTTP directly.
  • Batch reassembly: The datastore partitions and batches ledgers according to the config file (often one ledger per batch). For the case when the CLI is returning a range, the CLI should download all batches needed to cover the requested range, unpack them, extract the relevant ledgers, and reassemble them into a single LedgerCloseMetaBatch. Why: This tool isn't for copying a datastore, it's for collecting a range, and that is most useful if it is returned to the user in a single batch.

Network support:

Network Datastore URL
Mainnet (pubnet) https://aws-public-blockchain.s3.us-east-2.amazonaws.com/v1.1/stellar/ledgers/pubnet
Testnet https://aws-public-blockchain.s3.us-east-2.amazonaws.com/v1.1/stellar/ledgers/testnet/2025-12-17
Local (Quickstart w/ Galexie) http://localhost:8000/ledger-meta

Futurenet does not currently have a ledger meta datastore.

The pubnet and maybe testnet URLs are I think already hardcoded today and are used by the stellar snapshot create command and selected based on the current network. We can do same for this subcommand and consider making it configurable in the future as a separate mini project.

What alternatives are there?
  • Building one-off scripts/tools each time (current state — duplicated effort).

  • ⭐ The stellar ledger fetch command pulls LedgerCloseMeta from RPC. There's an argument I think that the existing ledger fetch command modified to support selecting different sources, because the data is so similar, with the repsonse being limited to meta information if the ledger meta datastore is the specific source. ⭐

Dominant language
Rust
Stars
123
Forks
141
Avg merge
2d 21h
Merged PRs (30d)
17

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stellar/stellar-cli

All issues in stellar/stellar-cli

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.