x402 paid agent starter (TypeScript + Python) with on-chain proof
Two starter templates for a paid agent listed on LAX (https://lax.kognai.ai), one per folder, each usable on its own:
| TypeScript | Python | |
|---|---|---|
| Paid route | typescript/src/app.ts: createApp({price, payTo, network, facilitator, description?}), a web standard fetch handler (Node, Hono, Bun, workers) |
python/app.py: create_app(...), FastAPI |
| LAX offer | typescript/lax-offer.json |
python/lax-offer.json |
| Listing script | typescript/src/list.ts listOffer({offer, registryUrl?, fetch?, pay}) and scripts/list.ts |
python/list_offer.py |
| Tests | npm test (node:test via tsx) |
pytest |
Both speak x402 version 1, exact scheme, USDC on Base (base) or Base Sepolia (base-sepolia):
GET /paid without X-PAYMENT answers 402 with {x402Version: 1, error, accepts: [requirements]}. The USDC asset is 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 on base and 0x036CbD53842c5426634e7929541eC2318f3dCF7e on base-sepolia, and maxAmountRequired is in atomic units (6 decimals).X-PAYMENT (base64 JSON) the app checks scheme and network, asks the facilitator to verify, then to settle, and only then does the work. It answers 200 with X-PAYMENT-RESPONSE (base64 JSON of the settlement). A payment that does not verify or settle gets 402, and the work is not done.GET /health is free.The facilitator comes from the configuration: an object with verify and settle, or a URL (default https://x402.org/facilitator, which settles x402 v1 on base-sepolia; https://facilitator.payai.network settles v1 on base).
On-chain proof (21 October 2026): each starter settled one real paid call of 0.01 test USDC on Base Sepolia through the x402.org facilitator: TypeScript https://sepolia.basescan.org/tx/0x352aa808ef460fdaf8de6a9ba8a0e5bac7f2cf7b26c426f6b9440cd0de13cacf and Python https://sepolia.basescan.org/tx/0xef8fb6cd9f8f6c4d8e0552d21bd7863743392371b13f64efa7762f6dbe93c648. Details and how to reproduce: PROOF.md.
Keys are read by the caller from the environment (LAX_PAYER_KEY, PAYER_KEY) and never logged. Every payment script has a spend cap (MAX_FEE_ATOMIC, default 10000 = 0.01 USDC).
Derived in part from the MIT AgentGate x402 service (https://agentgate-source.pages.dev/agentgate/). MIT licence.
agentgate-source: code mirror on Cloudflare Pages. All repos