Overview
Agent-to-Agent (A2A) payments enable AI agents to autonomously pay each other for services and tool access. No user intervention required after initial approval—agents handle signature generation, payment submission, and settlement verification. Key insight: Agents treat payments like API authentication—just another HTTP header to include.Why A2A Matters
Traditional payment flows break agent autonomy:Manual Flows
User must approve every transaction❌ Breaks automation
Private Keys
Agents need direct key access❌ Security nightmare
Custom Infrastructure
Build payment systems from scratch❌ High development cost
User Intervention
Manual signing for each payment❌ Poor UX
A2A Architecture
A2A payments combine three technologies:1. x402 Protocol (Payment Layer)
HTTP-native payment protocol using402 Payment Required status codes.
2. MCP (Tool Layer)
Model Context Protocol defines how agents call tools and functions.3. Smart Wallets (Identity Layer)
Crossmint smart wallets enable signing without private key management.Payment Flow
Let’s walk through a complete A2A payment:Code Example: Guest Agent
Here’s how the Guest Agent handles automatic payments:events-concierge/src/agents/guest.ts
Code Example: Host Agent
Here’s how the Host Agent defines paid tools:events-concierge/src/agents/host.ts
Multi-Tenant Architecture
For production A2A systems, use Cloudflare Durable Objects for per-user isolation:Stateful
In-memory state persists across requests
Isolated
Each user has their own wallet and data
Single-threaded
No race conditions or concurrency bugs
Auto-scaling
Created on-demand, hibernate when idle
Security Considerations
Signature Verification
Signature Verification
Always verify signatures match the payment message:
Nonce Management
Nonce Management
Use nonces to prevent replay attacks:
Balance Checking
Balance Checking
Verify payer has sufficient funds before executing business logic:
Transaction Verification
Transaction Verification
Confirm on-chain settlement before marking payment complete:
Rate Limiting
Rate Limiting
Prevent abuse with rate limits:
Error Handling
Agents must gracefully handle payment failures:Real-World Examples
Event RSVP
MCP-based event booking with autonomous paymentsStack: Cloudflare Durable Objects, MCP, x402
Tweet Agent
Pay to post tweets via AI agentStack: Next.js, Express, x402
Worldstore Agent
Amazon purchases via XMTP chat with gasless USDCStack: XMTP, Base, Crossmint
Ad Bidding
Claude agents competing for ad space with paymentsStack: Claude, x402, autonomous bidding
Best Practices
Start with Testnet
Start with Testnet
Use Base Sepolia and Circle’s USDC faucet for development:
- Network:
base-sepolia - Chain ID:
84532 - USDC:
0x036CbD53842c5426634e7929541eC2318f3dCF7e - Faucet: https://faucet.circle.com/
Confirm Before Payment
Confirm Before Payment
Always get user approval before signing payments:
Display Transaction Proofs
Display Transaction Proofs
Show users blockchain proof of payment:
Log Payment Events
Log Payment Events
Track all payment attempts for debugging:
Monitor Revenue
Monitor Revenue
Track earnings in real-time:
Next Steps
x402 Protocol
Deep dive into HTTP payment protocol
Smart Wallets
Learn about Crossmint smart wallet features
Payment Flow
See detailed payment flow diagrams
Build Event RSVP
Build your first A2A payment system