Skip to main content
All use cases
Machine paymentsAI-native

Your agent pays for what it uses. Under a budget, not a blank check.

An API answers with a 402 and a price. The agent checks the mandate its owner signed once, settles the call in USDC from its wallet slot, and gets the data back. The receipt is sealed to the mandate that allowed it. This rail is live in production on Base mainnet.

BeforeProvision keys, prepay, reconcile invoices
AfterPay per call, sealed to a mandate
1 USDC
spent per call, sealed with the mandate
Try it in the Sandbox
$0.001
Per call
Settled in USDC, inside the cap
Mainnet
In production
First CodeSpar rail fully live on Base
Over cap
Refused
A payment above the limit never touched the chain
Sealed
Every payment
Hash-chained to the mandate that allowed it
What the agent does

Find a service, pay it, seal the receipt.

The agent hits a market-data API it discovered on its own, gets a 402 with a price, verifies the mandate its owner signed, pays in USDC on Base, and gets the JSON back. A second call over the cap is refused before it reaches the chain.

  • Discovered the service on its own, no account and no card
  • Verified the signed mandate before paying: limit, scope, expiry
  • A $2 call against a $1 cap was refused before the chain
  • Receipt hash-chained to the mandate that authorized it
Market Data API
x402 · Base mainnet
Agent
GET /crypto-news
via codespar_pay · x402
HTTP 402. Pay $0.001 per call.
Mandate ok. Paid $0.001 in USDC on Base.
Railx402 · USDC · Base
Mandatecm_6GRE…
Amount$0.001
Receiptrcpt_ILLN…
200. Here is the JSON.
Next call is $2, over the $1 cap. Refused before the chain.
paid · sealed · under mandatercpt_ILLNDmWV
The pain

The conversation is the easy part.

Machine-to-machine payments today mean prepaid balances, shared keys, and invoices you reconcile later. An agent either has a blank check or no way to pay at all.

Provision an API key and prepay a balance for every service

The agent pays per call in USDC, no account to set up

Give the agent a blank check and hope it behaves

Every payment is checked against a mandate: limit, scope, expiry

Reconcile machine spend from provider invoices weeks later

Each payment is a sealed receipt, hash-chained to its mandate

Trust that an over-budget call just will not happen

A payment over the cap is refused before it touches the chain

How the agent does it

Machine spend with a budget.

The agent settles x402-priced calls in USDC from its wallet slot, always inside the mandate its owner signed. USDC on Base is one slot of the multi-rail wallet, and Pix is the center. This is the first CodeSpar rail proven fully in production.

01
Call
Agent

Agent hits the resource

02
402
x402

Service quotes a price

03
Verify
codespar_pay

Mandate cap, scope, expiry

Mandate
04
Settle
Coinbase CDP

USDC on Base, gasless

05
Seal
Audit ledger

Receipt to the mandate

Architecture

The agent calls a resource, receives a 402 with a price, and codespar_pay verifies the mandate (cap, scope, expiry) before settling in USDC on Base. The x402 leg is gasless via the facilitator relayer. The receipt is hash-sealed to the mandate so every machine payment reconstructs end to end.

In code

A few lines. The whole loop.

machine-spend-x402.ts
const session = await codespar.sessions.create();

// the agent hits an x402-priced resource and gets a 402 + quote
const res = await session.execute("codespar_pay", {
  rail: "x402",
  resource: "https://x402.example/crypto-news",
  maxUsdc: 1, // per-tx cap from the signed mandate
});

// paid in USDC on Base, inside the cap, sealed to the mandate
await session.verificationStatus(res.toolCallId);
1 USDC · sealedreceipt · rcp_machin
Featured tools
codespar_pay

Settles an x402-priced call in USDC from the wallet slot, inside the mandate cap.

Wallet (USDC slot)

Holds USDC on Base as one slot of the multi-rail wallet; Pix is the center.

Audit ledger

Hash-seals every machine payment to the mandate that authorized it.

See the meta-tool reference
MCP servers wired

Ship it this afternoon.

Open the sandbox, point a session at your providers, and run the whole loop against real rails in minutes — not the quarter it takes to build it by hand.

Machine spend (x402) — CodeSpar | CodeSpar