An API that bills per request can show the payments on the ledger, but customers dispute usage, not payments. Build an example that, at the end of a billing period, computes a usage statement from request logs and anchors its hash, so the provider can't quietly change the statement later.
Done when:
examples/mainnet-receipt-usage-statement/ with a script: input a request log (sample JSONL with fake client ids), output a statement (requests per endpoint, period start and end) and a signed receipt of the statement's sha-256.
check <statement.json> <CID> fails if a single count is edited. Covered by a test.
- No real customer data. The sample log is generated by a script in the folder.
- The README says the receipt proves the statement wasn't changed after it was anchored, not that the counts are correct.
How to anchor on mainnet (client only):
- Use the published CLI or SDK against the mainnet node:
npx nirium-cli@latest anchor --record '<json>' --sign --key-env NIRIUM_SECRET_KEY --tag wave-mainnet-usage-statement --url https://nirium-agent-mainnet.fly.dev (or the SDK: new Agent({ baseUrl: 'https://nirium-agent-mainnet.fly.dev' }) and anchorAuditRecord(), signing the statement below yourself). Free, no API key. Do not change any Nirium package in this PR.
- Sign with your own Stellar mainnet key (
NIRIUM_SECRET_KEY, statement nirium-audit-v1:<sha256>). Signing a receipt moves no funds.
- Anchor a hash or a small non-personal record (max 8 KB). Anchored content can stay public for good: no names, emails, addresses or account numbers of real people.
- Verify with
npx nirium-cli@latest verify <CID> --require-signature --json; do not build a new verifier.
- The README must say what a receipt proves and what it doesn't: the record hasn't changed since it was anchored and which key signed it, not that its content is true.
anchoredAt is the Nirium node's clock, not a ledger time.
Evidence (required):
- Your own Stellar mainnet account: it exists on Horizon and was created and funded by you (a few XLM for the base reserve), never by Nirium or by another contributor. Never commit the key.
- Two signed receipts on mainnet, anchored on two different UTC days, both produced by running your example, both with the tag
wave-mainnet-usage-statement. List both CIDs in the README with the verify --require-signature --json output (it must show signatureStatus: valid and your key). verify does not print the network, so also show the receipt document's network field, which must be stellar:pubnet.
- Tests run without network: mock the anchor call and cover the happy path plus the case described in "Done when".
- A short demo video in the PR description: a screen recording of 2 minutes or less. Say whether we may share it on Nirium's channels, with credit to you.
Receipts made for this issue are listed publicly as Stellar Wave activity, not as organic usage. One issue from this series per person.
Out of scope: charging with x402 on mainnet, moving or holding anyone else's funds, changing any Nirium package, Soroban contracts, personal data, and receipts that only repeat a transaction's payer, payee or amount (the ledger already shows those).
Update, 25 Nov 2026 (UTC): corrected the anchor command (--key-env was missing), the SDK option, and how to show the network. The rules did not change.
Drafted with Claude (Opus 5.5) and reviewed by @Eras256.