x402 Suite · infrastructure

x402-agent-wallet

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.

Pay in USDC on Base or USDC on Solana Rail-aware policies
npm install x402-agent-wallet

The problem

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.

Enforce it client-side

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
fetch 402 policy check sign & retry 200 + artifact PolicyViolationError nothing was signed

Or run the daemon

RoutePriceWhat you get back
POST /policy-check$0.001Signed verdict: allowed, reason, requiresApproval, every remaining budget, policy digest
POST /record-spendfree*Ledger entry for a settled payment
GET /ledgerfree*Spend history + per-rail totals
GET /policyfreeThe policy in force and its digest
POST /verifyfreeSignature 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-aware, end to end

RailNetworkpayToFacilitator
EVMbase-sepolia / base0x40252CFDF8B20Ed757D61ff157719F33Ec332402x402.org
Solanasolana / solana-devnetWwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwWPayAI

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.

Docs

Tutorial →

Run the daemon, take a 402, get a signed verdict, then move enforcement client-side.

API reference →

Every route and every library export, with schemas and denial reasons.

For AI agents →

Discovery, both rails, MCP integration, and where to get listed.

skill.md →

The agent-facing contract in one file.

.well-known/x402 →

Machine-readable manifest for x402 indexes.

OpenAPI 3.1 →

Including the 402 response and PaymentRequirements schema.