Two micropayment flows: pay-per-request and prepaid balance
Whether your agent pays per call or pre-funds a balance, the gateway handles invoice creation, on-chain verification, and upstream proxying automatically.
Pay-per-request
Client hits a gated endpoint and receives a 402 with an invoice. It pays on-chain, then retries with an X-Payment-Proof header. The gateway verifies the transaction on Neutaro and proxies the request upstream.
Prepaid balance
Client deposits NTMPI once via /prepaid/deposit. Subsequent requests include an X-Client-Id header and the gateway deducts from the balance per call — no repeated on-chain transactions.
Built for agentic AI and the machine-native economy
Everything a machine-to-machine micropayment layer needs, nothing it doesn't.
On-chain verification
Queries Neutaro REST API to confirm payment amount, memo, and block confirmations before allowing access.
Route-level pricing
Set a default price and override per-route with GATEWAY_ROUTES. Cheap reads, expensive writes.
Management API
JWT-protected endpoints for internal wallets, transactions, and a lightweight blockchain ledger.
Reverse proxy
Transparently forwards authenticated requests to your upstream API. Any backend, any language.
SQLite storage
Invoices, prepaid balances, and payment logs stored locally in a single file. Zero external dependencies.
Docker-ready
One-command deploy with docker compose up. Ubuntu deploy script included for bare metal.
Gateway API endpoint reference
Free endpoints for health checks, invoice lookups, and balance queries. Everything else goes through the 402 gate.
Free — no payment required
| Method | Path | Description |
|---|---|---|
| GET | /health | Health check with gateway config |
| GET | /invoices/:id | Check invoice status (triggers on-chain verification) |
| POST | /prepaid/deposit | Register a deposit (verifies tx on-chain first) |
| GET | /prepaid/balance/:clientId | Check prepaid balance |
Management — JWT protected
| Method | Path | Description |
|---|---|---|
| POST | /manage/auth/register | Register admin account |
| POST | /manage/auth/login | Login, get JWT token |
| POST | /manage/wallet | Create internal wallet |
| GET | /manage/wallet | List your wallets |
| GET | /manage/wallet/:id | Get wallet by ID |
| POST | /manage/transactions | Create internal transaction |
| GET | /manage/transactions/:id | Get transaction by ID |
402 Gate — catch-all
| Method | Path | Description |
|---|---|---|
| ANY | /* | All other requests require payment or prepaid balance |
Agent integration: Python and TypeScript examples
Wire the 402 flow into any agent in a few lines. The gateway handles invoicing and verification — your code just needs to pay and retry.
import requests, subprocess, os res = requests.get("http://gateway:4020/api/data") if res.status_code == 402: inv = res.json()["payment"] # Pay with ClawPurse subprocess.run([ "clawpurse", "send", inv["address"], inv["amount"], "--memo", inv["memo"], "--yes" ]) # Retry with proof res = requests.get( "http://gateway:4020/api/data", headers={"X-Payment-Proof": inv["invoiceId"]} ) data = res.json()
async function paidFetch(url: string) { let res = await fetch(url); if (res.status === 402) { const { payment } = await res.json(); // Pay with ClawPurse const { send, loadKeystore } = await import("clawpurse"); const { wallet, address } = await loadKeystore( process.env.CLAWPURSE_PASSWORD! ); await send( wallet, address, payment.address, payment.amount, { memo: payment.memo } ); // Retry with proof res = await fetch(url, { headers: { "X-Payment-Proof": payment.invoiceId } }); } return res.json(); }
Install and run the gateway in under a minute
# Clone and install git clone https://github.com/mhue-ai/clawpurse-gateway.git cd clawpurse-gateway && npm install # Configure cp .env.example .env # Set GATEWAY_PAYMENT_ADDRESS and JWT_SECRET # Start a test upstream npm run test:upstream # Start the gateway npm run dev # Test the 402 flow curl http://localhost:4020/api/test # Pay, then retry with proof: curl -H "X-Payment-Proof: <invoiceId>" \ http://localhost:4020/api/test
TypeScript microservice architecture
A focused TypeScript codebase — gateway logic, four internal services, and middleware. 46 unit tests cover every layer.
Gateway configuration via environment variables
All settings via env vars or .env file.
| Variable | Default | Description |
|---|---|---|
| PORT | 4020 | Gateway listen port |
| GATEWAY_UPSTREAM | http://localhost:3000 | Upstream API to proxy |
| GATEWAY_PAYMENT_ADDRESS | — | Your Neutaro wallet address (required) |
| GATEWAY_DEFAULT_PRICE | 0.001 | Default price per request in NTMPI |
| GATEWAY_ROUTES | — | Route pricing overrides |
| GATEWAY_REST | https://api2.neutaro.io | Neutaro REST API endpoint |
| GATEWAY_MIN_CONFIRMATIONS | 1 | Block confirmations required |
| GATEWAY_INVOICE_TTL | 300 | Invoice validity in seconds |
| GATEWAY_PREPAID | false | Enable prepaid balance system |
| GATEWAY_DB | ./gateway.db | SQLite database path |
| JWT_SECRET | — | Secret for management API JWT (required) |
Part of the Timpi, Neutaro & ClawPurse ecosystem
ClawPurse Wallet
The local NTMPI wallet with encrypted keystores, guardrails, staking, and destination allowlists. The reference client for paying through the gateway.
Neutaro Blockchain
The Cosmos SDK chain powering NTMPI. All gateway payments are verified directly against Neutaro's REST API — no oracles, no bridges.
Timpi Network
Privacy-first decentralised search with an open Data API and DePIN nodes. ClawPurse Gateway lets you monetise any Timpi-powered service via micropayments.
Timpi Drip Faucet
Agent-friendly NTMPI faucet with proof-of-work challenge instead of CAPTCHA. OpenClaw-authenticated agents get a higher throughput drip for faster onboarding.
Ledger Timpi
Free NTMPI cost basis calculator and tax tool. Auto-fetches transfers, staking rewards, and node payouts from the Neutaro chain — calculates USD cost basis with FIFO/LIFO/HIFO and generates IRS Form 8949.
x402 Payment Protocol
Coinbase's open HTTP 402 standard routes every payment through a centralized facilitator that controls settlement. ClawPurse Gateway takes the opposite approach: peer-to-peer payments verified directly on Neutaro — no middleman, no EVM lock-in, no Coinbase SDK. Add prepaid balances for zero-latency repeat access, route-level pricing in one env var, and a full audit trail in SQLite. One Docker command to deploy; zero external dependencies to operate.
Frequently asked questions
What is ClawPurse Gateway?
An x402-compatible open-source HTTP reverse proxy that implements the 402 Payment Required status code to gate any API behind NTMPI micropayments on the Neutaro blockchain. It supports pay-per-request and prepaid balance flows for AI agents, agentic wallets, and machine-to-machine commerce.
How does ClawPurse Gateway relate to x402?
x402 is an open payment protocol, initially developed by Coinbase, that standardizes HTTP 402 Payment Required for web-native micropayments. ClawPurse Gateway implements the same pattern — 402 invoice → on-chain payment → retry with proof — but on the Neutaro (Cosmos SDK) blockchain instead of EVM chains. This makes ClawPurse the x402 implementation for the Cosmos ecosystem. Learn more →
How does the HTTP 402 payment flow work?
A client requests a gated endpoint and receives a 402 response with an invoice containing an invoiceId, amount, address, and memo. The client pays on-chain using ClawPurse or any Neutaro wallet, then retries the request with an X-Payment-Proof header. The gateway verifies the transaction on Neutaro and proxies the request upstream.
What is NTMPI and how do I get it?
NTMPI is the native token of the Neutaro blockchain, part of the Timpi decentralised search network. You can get free NTMPI from the Timpi Drip Faucet, acquire it on MEXC via the NTMPI/USDT spot pair, or use the ClawPurse Get portal for one-click access to Uniswap, MEXC, and OraiDEX.
Does the gateway hold my funds?
No. ClawPurse Gateway is fully non-custodial. It verifies payments by querying the Neutaro REST API directly — the gateway never touches funds, holds keys, or acts as an intermediary. You self-host the gateway on your own infrastructure.
Can AI agents use ClawPurse Gateway autonomously?
Yes. The gateway is designed for agentic AI and machine-to-machine workloads. Agents can programmatically parse the x402 invoice, pay on-chain via the ClawPurse agentic wallet API, and retry with the payment proof header — all without human intervention.
Buy Mhue a Timpi coffee ☕
If the gateway is saving your stack ops time, tip the builders.
neutaro1e8xal8tqdegu4w48z3fphemd3hc07gech3pfek
Memo optional — just let us know what you shipped!