agent-x402
Pay per API call in USDC on Base — with a spend policy a prompt injection cannot bypass.
x402 turns a 402 into a signed USDC transfer, which means an agent can buy inference without an account. It also means an agent can spend money. This is the client that pays, and the policy that decides whether it may.
View on GitHub
npm
README
What it does
x402 v2, exact scheme EIP-3009 transferWithAuthorization, USDC on Base, 15-minute validity window.
Spend policy Daily cap, per-request cap, payment count, payee allow-list, blocked contracts, per-network cap.
Policy outside the model The rules are enforced in code before anything is signed.
Any endpoint The client is protocol-level, not vendor-specific.
MCP server x402-balance, x402-quote, x402-pay and x402-policy as agent tools.
Audit trail Every payment is recorded with its amount, model and time.
Usage
Create a walletax402 new
See the balanceax402 balance
Price a callax402 quote https://api.venice.ai/api/v1/chat/completions
Pay for a callax402 pay https://api.venice.ai/api/v1/chat/completions '{"model":"claude-haiku-5-5","messages":[{"role":"user","content":"hi"}]}'
Read the spendax402 policy
How it works
Request the endpoint: a 402 comes back with the price, the network and the payee.
Check the policy: caps, allow-list and blocked contracts are evaluated before signing.
Sign the transfer with EIP-3009 and retry with the payment attached.
Record the spend so the daily budget stays honest.
Questions
(rows) =>
rows
.map(
([q, a]) =>
`
${q} ${a}
`,
)
.join("\n")
agent-x402 · MIT
source
issues
USDC on Base: 0x8aC6a229f254980CCd3Dd35CF5E1B7c08880B40E