Nirium

Open-source verifiable receipts (Audit Trail), agentic payments (x402/MPP) and treasury execution for Stellar/Soroban.
This repository contains the TypeScript and Python SDKs, the MCP server, the CLI, examples and quickstarts that let any developer:
- Anchor tamper-evident audit trails: SHA-256 content hash pinned to IPFS, optionally carrying an ed25519 signature that proves who declared the fact, not just that it is unaltered. Records are pinned with Pinata. To read them back,
nirium verify and the verify-audit-cid Action try a dedicated Filebase gateway first and fall back to shared public gateways, which often answer 429 under load.
- Get paid by AI agents: put your own API behind an x402 pay-gate in one call with
x402Serve(), or pay for someone else's with initX402().
- Cap what your own agent can spend: both SDKs refuse a payment above $1 of USDC by default unless you raise the cap (TypeScript through
@x402/core, Python since 0.12.0, which also refuses a 402 offered on another network). On top of that, an experimental pre-sign policy hook (initX402({ policy }), shipped in 0.16.0) asks your own ALLOW/DENY policy before any payment is signed - see packages/sdk/README.md#pre-sign-policy-hook-experimental for its real scope and what it does not cover.
- Automate on-chain treasury: a Nirium agent moves idle capital into a CETES strategy (tokenized Mexican T-bills via Etherfuse) and back, over a vault you own. The agent can propose a rebalance without ever holding a signing key. On mainnet, deploying, depositing, proposals and autonomous execution (the agent signs) are invite-only until we have a written legal opinion; withdrawing is always open.
Software-only and non-custodial: independent partners execute settlement, the client signs every fund movement, and Nirium never holds client funds.
Reviewing Nirium? docs/FOR-REVIEWERS.md is a ten-minute path through things you can check yourself. Every piece of evidence, with its network and date, is in EVIDENCE.md. Verify any receipt with no account at nirium.xyz/verify, and see live usage, each row labeled with its source, at nirium.xyz/stats.
Design questions and limits, including what a receipt does and doesn't prove: docs/DESIGN-FAQ.md.
How a payment works
One paid request, end to end. Every step runs on the client or an independent partner; Nirium never holds the funds. The policy step and the receipt are optional.
sequenceDiagram
autonumber
participant A as Your app, backend or AI agent<br/>(nirium SDK)
participant P as Your policy<br/>(optional, experimental)
participant S as Paid API<br/>(x402Serve)
participant F as x402 facilitator<br/>(independent: OpenZeppelin)
participant X as Stellar
participant N as Nirium Audit Trail
participant I as IPFS
participant V as Anyone
A->>S: request
S-->>A: 402 Payment Required, price in USDC
A->>P: allow this payment?
P-->>A: ALLOW (DENY or WAIT: nothing is signed)
Note over A: signs with YOUR key, capped at $1 by default
A->>S: retry with the signed payment
S->>F: verify and settle
F->>X: submit, facilitator pays the network fee
S-->>A: 200 + the data
A->>N: anchor a receipt (optional) for what the ledger can't show: the policy decision and what the call was for, a DENY too
N->>I: pin
N-->>A: CID
V->>I: fetch the CID, recompute the hash, check the signature
What a receipt adds over the ledger
A Stellar payment is already public and can't be changed: anyone can check the payer, payee, asset and amount from the transaction hash. A receipt that only repeats those fields proves nothing new. Audit Trail is for what the ledger doesn't hold:
- What a policy decided, including payments it refused and never signed (no transaction exists for those) or held until a person approved them.
- What a payment was for: the resource, request or delivery it paid for.
- Documents and events that never touch the chain: quotes, accepted terms, approvals, proof of delivery, and a later correction that keeps the original.
- Who declared it, through the optional ed25519 signature.
If everything you want to prove is already in the transaction, link the transaction.
Packages
| Package |
Install |
Version |
Description |
| TypeScript SDK |
npm install nirium |
 |
Client for the Nirium API, x402/MPP payments, signals, webhooks, plus x402Serve() to charge for your own API. |
| Python SDK |
pip install nirium · pip install 'nirium[langchain]' |
 |
Async client with the same surface, plus NiriumX402Tool for LangChain agents. |
| MCP server |
npx nirium-mcp |
 |
Receipts, Reporting and x402 tools for Claude Desktop, Cursor, and any MCP-compatible IDE. Since 0.7.0 it loads 14 tools; the 11 treasury tools are opt-in and testnet only. |
| CLI |
npm install -g nirium-cli |
 |
Scaffold and interact with Nirium from the terminal. Includes nirium verify to independently verify Audit Trail CIDs. |
The source in packages/ matches what is published (the overrides in packages/sdk and packages/cli were added on 2026-10-23 for this repo's own dependency audit; npm ignores a dependency's overrides, so they don't change what you install). The two SDKs share full Treasury parity (12 methods, proposeTreasuryRebalance()/propose_treasury_rebalance() included). x402Serve() stays TypeScript-only - it's Express middleware, server-side Node, with no meaningful equivalent in an async Python client. Both SDKs include a resilient, auto-reconnecting WebSocket client (backoff, jitter, dedup; ResilientSignalClient in TypeScript), though the hosted stream at /ws/signals did not accept connections when checked on 18 Nov 2026. Python also ships a LangChain BaseTool (pip install nirium[langchain]) that TypeScript doesn't have.
Signing with a social-login wallet instead of a raw keypair? See nirium-pollar-adapter, a separate package that adapts Pollar's embedded-wallet SDK to sign x402 payments and audit records through this SDK.
Quickstart: pay for an API (TypeScript)
npm install nirium
import { Agent } from 'nirium';
const agent = new Agent({ apiKey: 'sk_inst_your_key_here', baseUrl: 'https://nirium-agent.fly.dev' });
const market = await agent.getMarket();
console.log(market);
Update, 2026-10-24 (checked against the live API that day): this
previously showed getMarket() with no apiKey at all. GET /api/market
requires auth server-side and returns 401 without one - get a key from
POST /api/auth/keys or the /keys console.
Quickstart: charge for your API
The other side of the counter. Wiring x402 by hand is ~25 lines of facilitator client, per-method auth headers, per-network scheme registration and a route table whose shape you have to reverse-engineer. This is the same thing with the defaults that already run in production:
npm install nirium express @x402/express @x402/core @x402/stellar
import express from 'express';
import { x402Serve } from 'nirium';
const app = express();
// No `network` set, so this defaults to stellar:testnet - get a free
// testnet key from channels.openzeppelin.com/testnet/gen. A mainnet key
// returns 401 against testnet; pass network: 'stellar:pubnet' plus a
// mainnet key (channels.openzeppelin.com/gen) to charge for real.
app.use('/premium', x402Serve({
payTo: 'G...', // your Stellar address
routes: { 'GET /signals': '$0.02' },
facilitatorApiKey: process.env.X402_FACILITATOR_API_KEY,
}));
app.listen(3000);
Any AI agent can now pay for your endpoint in USDC: no account, no card, no subscription, no human awake.
Update, 2026-10-24 (checked against the source that day): this previously
omitted facilitatorApiKey/facilitatorUrl, express/app itself (the
snippet called app.use() with no app ever created), and which network
it runs against by default (testnet). Get a key from OpenZeppelin Channels,
or point facilitatorUrl at your own facilitator instead.
Off by default: x402Serve() verifies and settles the payment and does
nothing else unless you pass guard (nirium 0.15.0 and later): with a store,
a payment proof can be used only once per route, and guard.rateLimit adds a
per-IP limit. See packages/sdk/README.md
and issue #91 (closed),
where the design came from a real production deployment.
See docs/ for full quickstarts, including "Pay for an x402 API in 5 minutes" (🇪🇸 Español), and serverless Audit Trail anchoring with waitUntil, plus examples/ for 33 example folders, among them Express and Next.js (TypeScript), Go, Rust, LangChain x402 (Python), non-custodial treasury vault, resilient WebSocket signals, one-click Vercel deploy, Unity/C# game paywall, RouteDock discovery manifest, Stellar Disbursement Platform audit bridge, audit-forensic-bridge, per-agent daily spend policy, smart settlement of a verified delivery, and an Open Policy Agent policy behind the pre-sign hook, and agent tools for OpenAI Agents, Google ADK, CrewAI and the Vercel AI SDK. Python: FastAPI x402 seller and treasury vault. Audit Trail receipts: agent logbook, model provenance, proof of delivery, logistics checkpoints, IoT readings, reproducible notebook, tamper-evident announcements, accepted terms and a correction that keeps the original. Treasury and payouts on testnet: batch payout, vault monitor, risk signals and DAO grants signed 2-of-3. Also a Soroban oracle sold over x402. For real production findings (not marketing copy), see the devlog.
Networks
Live on both Stellar networks. They are not two copies of the same thing.
Status at a glance
Uptime of nirium.xyz and the public mainnet and testnet endpoints is checked on a schedule by GitHub Actions at nirium-protocol.github.io/status (repo: the results and history are committed there in public). It measures availability, not payments or usage.
| Product |
Status |
| x402 |
Live on mainnet (last settled payment 24 Nov 2026, our own test) |
| Audit Trail |
Live on mainnet (last anchor 24 Nov 2026) |
| Reporting |
Live on mainnet |
| Treasury Rebalance |
Mainnet, invite-only (4 self-funded rebalances, last 6 Aug 2026) |
| Payouts |
Mainnet, invite-only (no mainnet runs yet) |
Policy hook (pre-sign ALLOW/DENY) |
Experimental (TypeScript SDK; Python SDK since 0.12.9) |
| MPP Charge |
Testnet only (client: use nirium@0.19.8 until @stellar/mpp supports stellar-sdk 17) |
The tables below back each row with a transaction hash or a live endpoint - this one is just the summary.
Update, 2026-10-24 (checked against the live /api/v1/mpp/info on both
boxes that day): that applies to x402 and the treasury path below, not to
MPP Charge. MPP is implemented and charge.enabled: true on both
networks, but it has only ever settled on testnet (pull and push, 15 Oct
2026); mainnet is unverified. Don't read "live on both networks" as covering
MPP - see packages/sdk/README.md#mpp-charge-experimental.
Mainnet (real value). The API box holds no signing key by design; a separate process with no HTTP surface signs autonomous rebalances, and clients sign their own fund movements.
That third transaction is the point: the agent moved funds it does not own, and the contract gave it no way to take them out. Nirium holds only the vault's RebalanceManager role, and rebalance() accepts no destination address: withdrawal is not forbidden, it is inexpressible.
Testnet (no real value, where the loop and the key live, and where you should build).