AI agents already do real work: they scrape, summarize, write code, handle support. But there's one thing none of them can do: open a bank account. If your agent provides a service to another agent, how does it get paid?
A few weeks ago I shipped my answer to production: a payment gateway where one agent pays another in USDC — no accounts, no API keys, and the payer doesn't even need ETH for gas. It's live at https://agentpay.zone with real payments streaming in public. Here's what I learned building it.
The protocol: HTTP 402, the status code that waited 30 years
HTTP reserved 402 Payment Required decades ago "for future use". The future is x402: an open protocol (now governed by the x402 Foundation under the Linux Foundation, with Coinbase, Google, Stripe, Visa and Circle among its members) that defines how to charge for an HTTP call with stablecoins.
The whole flow fits in four steps:
# 1. The agent requests the resource, unpaid
curl https://agentpay.zone/weather
# 2. The server answers 402 with the payment terms
# (price, token, recipient, network) in the PAYMENT-REQUIRED header
HTTP/1.1 402 Payment Required
PAYMENT-REQUIRED: eyJ4NDAyVmVyc2lvbiI6MiwiYWNjZXB0cyI6W3sic2NoZW1lIjoi...
# 3. The agent signs an EIP-3009 authorization locally and retries
curl https://agentpay.zone/weather -H "PAYMENT-SIGNATURE: eyJ4NDAyVmVyc2lvbiI6..."
# 4. The server verifies, settles on-chain and serves the resource
{"ciudad":"Madrid","temperatura_c":21,"pago":{"tx":"0x71512abd..."}}
The magic is in step 3: the agent never sends a transaction. It signs an EIP-712 message (transferWithAuthorization, EIP-3009) saying "move exactly N USDC from my wallet to theirs, valid between these two timestamps, with this nonce". Anyone can submit that signature to the contract — and that anyone is the server, which pays the gas and gets paid. The buyer never needs ETH, gas, or a prior approval.
What's behind it (and how small it is)
The gateway is an Express app with viem in a 300 MB / 0.5 CPU Docker container. At idle it uses 30 MB and 0% CPU. It verifies the signature locally (free), checks the anti-replay nonce against the contract, simulates settlement before sending it (free, no gas), and only then settles. The entire security pipeline runs before spending a single wei.
The four things that broke (so they don't break you)
1. The testnet USDC's EIP-712 domain is not what you think. On Base mainnet the token is named "USD Coin", but on Base Sepolia it's "USDC". Same asset, different domain string, invalid signature with a cryptic FiatTokenV2: invalid signature. I solved it by comparing the on-chain DOMAIN_SEPARATOR() with my computed one — not by reading docs. Lesson: verify the contract's name() on YOUR network.
2. Testnet faucets are the weakest link. Three faucets down or retired. Workaround: bridge the ETH from Ethereum Sepolia through the official L1StandardBridge, whose address I verified on-chain by calling OTHER_BRIDGE() on the L2 predeploy. Watch out: my first deposit reverted for requesting too high a minGasLimit (200,000); 100,000 went through.
3. The hole almost nobody checks: verifying you're the one getting paid. During a security review I found my gateway verified signatures perfectly… but never checked that authorization.to was my wallet or that value covered the price. An agent could have paid itself while I paid the gas. Three lines fixed it; the lesson is that verifying the signature is not verifying the payment.
4. The anti-replay source of truth is the contract, not your database. My local nonce registry would know nothing if the same payment got settled elsewhere. The gateway now reads authorizationState(authorizer, nonce) on-chain before settling, and simulates the transaction before sending it: reverts get caught without burning gas.
x402 V2 and why compatibility matters
The protocol has moved to V2: PAYMENT-REQUIRED / PAYMENT-SIGNATURE / PAYMENT-RESPONSE headers and CAIP-2 network identifiers (eip155:84532). The gateway speaks V1 and V2 simultaneously, so any agent with a current x402 SDK can pay with zero special configuration. A 27-test regression suite (real payments, replays, malformed signatures, rate limiting) runs against production on every deploy.
Try it, break it, tell me about it
Everything above is live at https://agentpay.zone — the landing page shows real payments in real time, each linked to the block explorer. If you're building agents that provide services (APIs, data, scraping, content) and want other agents to be able to pay you, I'm opening a private beta: https://agentpay.zone/beta
I'm looking for 5–10 teams for the first cohort, with personal onboarding and founder pricing. The English-speaking market is full of noise about how agents spend. I'm building the other half: how they get paid.
AgentPay — payment infrastructure for the AI agent economy. Current network: Base Sepolia (testnet, no real value). Mainnet with the first customer.
Top comments (0)