AI agents are increasingly handling complex tasks like coding and support, yet they remain economically isolated, unable to open bank accounts or process payments. A recent production launch by AgentPay addresses this gap by introducing a payment gateway where agents transact in USDC using the x402 protocol. Live at agentpay.zone, this system allows one agent to pay another without requiring the payer to hold ETH for gas or maintain traditional API keys, effectively decoupling service consumption from traditional banking infrastructure.
The Protocol: Awakening HTTP 402
The core innovation relies on HTTP status code 402, reserved for future use decades ago but now standardized by the x402 Foundation under the Linux Foundation. Major players including Coinbase, Google, Stripe, Visa, and Circle back this open protocol. The workflow is streamlined: an agent requests a resource, the server responds with 402 and payment terms in a PAYMENT-REQUIRED header, the agent signs an EIP-3009 authorization locally, and the server settles the transaction on-chain. This method ensures the buyer never needs to submit a transaction or hold gas tokens.
Technical Implementation and Security Pitfalls
The gateway operates on a minimal Express app with viem, running in a 300 MB Docker container that consumes negligible resources at idle. The developer highlighted four critical failures encountered during testing. First, testnet USDC domains differ from mainnet, causing cryptic signature errors; the fix involved verifying the contract's name() on the specific network. Second, testnet faucets proved unreliable, requiring manual bridging via the L1StandardBridge with careful gas limit adjustments.
Verification and Replay Protection
A significant security oversight was initially present: the gateway verified signatures but failed to confirm that the payment recipient was the gateway's own wallet or that the value covered the price. This allowed agents to potentially pay themselves while the server absorbed gas costs. Additionally, the anti-replay mechanism was shifted from a local database to the on-chain contract state, reading authorizationState before settlement. This ensures that duplicate payments are caught without burning gas, simulating the transaction to revert invalid attempts.
Key Takeaways
- HTTP 402 is no longer theoretical; it is actively used for stablecoin payments via the x402 protocol.
- EIP-3009 allows agents to sign authorizations locally, removing the need for ETH gas fees on the payer's side.
- Security verification must include checking the recipient address and amount, not just the signature validity.
- On-chain state is the only reliable source of truth for preventing replay attacks in decentralized payment systems.
The Bottom Line
AgentPay demonstrates that the infrastructure for an autonomous agent economy is finally viable, but developers must rigorously verify on-chain state and recipient details to avoid subtle financial exploits.