x402 payment facilitator for AI agent micropayments on Nano (XNO)
nanoroute is an early-stage TypeScript project in the AI payments / x402 ecosystem. It currently has 4 GitHub stars and 0 forks.
x402 payment facilitator for Nano (XNO) — enabling AI agents to pay for APIs with zero-fee, sub-second micropayments.
NanoRoute is an open-source x402 facilitator that lets AI agents pay for any API or digital resource using Nano. It handles the full payment lifecycle: verification, on-chain broadcast, off-chain ledger tracking, and batch settlement to merchants — all with zero transaction fees.
The x402 protocol enables AI agents to pay for APIs at the HTTP level — no accounts, no API keys, just pay-per-request. NanoRoute implements this for Nano because:
AI Agent Merchant API NanoRoute Facilitator
│ │ │
├── GET /api/data ──────────▶│ │
│ │◀── 402 Payment Required ─────│
│◀── 402 + price + payTo ───│ │
│ │ │
│ [sign Nano send block] │ │
│ │ │
├── POST /api/data ─────────▶│ │
│ + X-PAYMENT header │── POST /x402/verify ────────▶│
│ │ │── broadcast block to Nano L1
│ │ │── record in off-chain ledger
│ │◀── { valid: true, txHash } ──│
│◀── 200 + data ────────────│ │
│ │ │
│ │ [settlement engine runs periodically]
│ │ │── batch-settle to merchant on Nano L1
X-PAYMENT header/x402/verifyA public NanoRoute facilitator is running and available for anyone to use:
| Facilitator URL | http://204.168.181.90:3402 |
| Health | http://204.168.181.90:3402/health |
| Dashboard | http://204.168.181.90:3402/dashboard |
| Status | http://204.168.181.90:3402/status |
Merchants can point their middleware at this URL to start accepting Nano payments immediately — no need to run your own node.
# Clone
git clone https://github.com/robgilmore26/nanoroute.git
cd nanoroute
# Install
npm install
# Configure
cp .env.example .env
# Edit .env — set your POOL_SEED (generate at https://nault.cc)
# Run
npx tsx src/index.ts
You should see:
╔══════════════════════════════════════════════╗
║ NanoRoute — x402 Nano Facilitator ║
╠══════════════════════════════════════════════╣
║ Pool: nano_3mcj4sh6sshg551wyqzww8pd... ║
║ Fee: 0 bps (0%) ║
║ Settle: every 300s ║
║ Port: 3402 ║
╚══════════════════════════════════════════════╝
Dashboard: http://localhost:3402/dashboard
Install the middleware and add it to your Express app:
import { nanorouteMiddleware } from 'nanoroute-express';
app.use(nanorouteMiddleware({
facilitator: 'http://204.168.181.90:3402', // public node (or run your own)
merchantAddress: 'nano_1youraddress...',
routes: {
'/api/market-data': { amount: '0.0001', description: 'Market data' },
'/api/premium': { amount: '0.001', description: 'Premium analytics' },
'/api/reports/*': { amount: '0.005', description: 'Research reports' },
}
}));
Unpaid requests get a 402 with pricing. Paid requests pass through to your route handler with req.nanoroute.txHash attached.
import { NanoRouteAgent } from 'nanoroute-agent';
const agent = new NanoRouteAgent({
seed: process.env.AGENT_SEED,
accountIndex: 1,
maxPaymentXno: '0.01', // safety cap
});
// One-liner: probe, pay, and fetch
const result = await agent.fetch('http://api.example.com/market-data');
console.log(result.body); // the paid resource
Or inspect the quote first:
const quote = await agent.getQuote('http://api.example.com/market-data');
console.log(`Cost: ${quote.amountFormatted}`); // "0.0001 XNO"
const result = await agent.pay(quote);
| Endpoint | Method | Description |
|---|---|---|
/x402/verify |
POST | Verify and broadcast an agent payment. Called by merchant middleware. |
/x402/requirements |
POST | Generate 402 payment requirements for a resource. |
/status |
GET | Pool state, routing stats, recent transactions. |
/pool/balance |
GET | Live on-chain pool wallet balance. |
/health |
GET | Health check. |
/dashboard |
GET | Web UI showing pool stats and transaction history. |
You can use the public node or run your own. Anyone can run a NanoRoute facilitator node. The routing fee is configurable — set ROUTING_FEE_BPS=0 for free routing, or set a fee (e.g., 100 = 1%) if you want to earn from transaction volume.
# .env
POOL_SEED=your_64_or_128_hex_seed
ROUTING_FEE_BPS=0 # 0 = free routing, 100 = 1% fee
SETTLEMENT_INTERVAL_SECONDS=300
Run the full agent-pays-merchant flow locally:
# Terminal 1: Start facilitator
npx tsx src/index.ts
# Terminal 2: Start example merchant
npx tsx examples/merchant-server.ts
# Terminal 3: Run agent (needs funded wallet)
npx tsx examples/agent-sdk-demo.ts
nanoroute/
├── src/
│ ├── index.ts # Entry point
│ ├── types/index.ts # Core type definitions
│ ├── db/ledger.ts # SQLite off-chain ledger
│ ├── routes/api.ts # Express API routes
│ └── services/
│ ├── verifier.ts # x402 payment verification + routing
│ ├── settlement.ts # Batch settlement engine
│ ├── nano-rpc.ts # Multi-node RPC client with failover
│ └── auto-receive.ts # Auto-pocket receivable blocks
├── packages/
│ ├── agent-sdk/ # nanoroute-agent — SDK for paying agents
│ └── middleware/ # nanoroute-express — merchant middleware
├── examples/
│ ├── merchant-server.ts # Example gated API server
│ ├── agent-pays-merchant.ts # Manual E2E flow
│ └── agent-sdk-demo.ts # SDK-based E2E flow
└── dashboard/
└── index.html # Live monitoring dashboard
NanoRoute builds on the growing Nano x402 ecosystem:
MIT — see LICENSE
The agent-native LLM router for autonomous agents. 55+ models (8 free), <1ms local routing, USDC payments on Base & Solana via x402.
A payments protocol for the internet. Built on HTTP.
A local-first AI agent with persistent memory, emotional intelligence, and a peer-to-peer skills economy.
The trust layer for agent-to-agent commerce — natural-language mandates, ERC-7710 delegated permissions, x402 payments, escrow, and dispute resolution as one open, catch-all Agent Skill / Claude Code plugin.
Self-healing infrastructure for AI agent payments. 90.3% auto-recovery.
The AI agent with a wallet — spends USDC autonomously to get real work done. Apache-2.0, TypeScript.