The spending governor for agents that pay with x402. Budgets, per-merchant and per-rail caps, approval thresholds — enforced before anything is signed, and answered with a verdict you can prove.
npm install x402-agent-wallet
Give an agent a funded wallet and an x402 client and it can spend money in a loop, at machine speed, with no human in the path. The failure modes are not exotic: a retry storm on a $0.05 endpoint, a prompt-injected merchant, a pricing bug that turns $0.001 into $1.00.
maxValue in x402-fetch caps a single payment. That is not a budget. This is the budget — plus the caps, the allowlists, the approval threshold, and a signed record of every decision.
import { wrapPayerFetch, PolicyViolationError } from "x402-agent-wallet";
import { createSigner } from "x402-fetch";
const payFetch = wrapPayerFetch(fetch, {
signer: {
evm: await createSigner("base-sepolia", process.env.EVM_KEY!),
svm: await createSigner("solana", process.env.SOLANA_KEY!),
},
policy: {
dailyBudgetUsd: 1,
perRequestMaxUsd: 0.05,
perMerchantDailyUsd: { "api.example.com": 0.25 },
perRailDailyUsd: { solana: 0.5 },
approvalThresholdUsd: 0.02,
preferRail: "evm",
},
});
await payFetch("https://api.example.com/paid"); // PolicyViolationError if blocked
| Route | Price | What you get back |
|---|---|---|
POST /policy-check | $0.001 | Signed verdict: allowed, reason, requiresApproval, every remaining budget, policy digest |
POST /record-spend | free* | Ledger entry for a settled payment |
GET /ledger | free* | Spend history + per-rail totals |
GET /policy | free | The policy in force and its digest |
POST /verify | free | Signature check on a verdict |
*requires X-Admin-Key. A denial is a 200 with allowed: false — you paid for the answer, and "no" is the answer.
| Rail | Network | payTo | Facilitator |
|---|---|---|---|
| EVM | base-sepolia / base | 0x40252CFDF8B20Ed757D61ff157719F33Ec332402 | x402.org |
| Solana | solana / solana-devnet | WwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW | PayAI |
allowedRails gates which chains the agent may touch, perRailDailyUsd caps each independently, preferRail picks when both are offered, and the ledger reports spentTodayByRail. On Solana the facilitator sponsors the network fee, so the agent needs only USDC — no SOL.
Run the daemon, take a 402, get a signed verdict, then move enforcement client-side.
Every route and every library export, with schemas and denial reasons.
Discovery, both rails, MCP integration, and where to get listed.
The agent-facing contract in one file.
Machine-readable manifest for x402 indexes.
Including the 402 response and PaymentRequirements schema.