Overview
This guide walks through complete payment flows for Crossmint Agentic Finance, from initial request to on-chain settlement. We’ll cover both simple HTTP paywalls and complex agent-to-agent transactions.Simple HTTP Paywall Flow
The most basic x402 flow: a client pays to access a protected API endpoint.Sequence Diagram
Step-by-Step Breakdown
Client Makes Initial Request
Client attempts to access protected endpoint without payment:Request headers:
Server Returns 402 Payment Required
Client Signs Payment Message
Client creates EIP-712 signature:For pre-deployed wallets: Signature includes ERC-6492 wrapper
Agent-to-Agent MCP Flow
More complex flow involving two agents communicating via Model Context Protocol (MCP).Sequence Diagram
Step-by-Step Breakdown
User Requests Action
User asks their agent to perform a paid action:Guest agent detects this requires calling the
rsvpToEvent MCP tool.Guest Agent Calls MCP Tool
Host Returns 402 Payment Required
Host MCP server checks for payment, finds none:402 Response:See events-concierge/src/agents/host.ts:158-202
Guest Confirms Payment with User
Guest agent’s User sees clear payment details and approves.
onPaymentRequired callback triggers:Guest Wallet Signs Payment
Guest wallet creates ERC-6492 signature (pre-deployed):Signature includes:
- Factory address
- Deployment bytecode
- Inner signature
- ERC-6492 magic suffix
Host Verifies & Settles Payment
Host calls facilitator to verify signature and settle:Facilitator:
- Verifies ERC-6492 signature
- Deploys guest wallet (if not already deployed)
- Executes USDC transfer from guest to host
- Returns transaction hash
Host Records RSVP & Revenue
After payment verified, Host executes business logic:See events-concierge/src/shared/eventService.ts
Wallet Deployment Flow
Special case: Guest wallet’s first payment also deploys the wallet on-chain.Sequence Diagram
ERC-6492 Signature Structure
Error Scenarios
Real-world payment flows must handle errors gracefully.Insufficient Balance
Client handling:Invalid Signature
Common causes:- Wrong chain ID in domain
- Incorrect message structure
- Tampered signature
- Wrong signer address
Network Failure
Retry logic:Best Practices
Always Verify Server-Side
Always Verify Server-Side
Never trust client-provided payment claims:
Store Transaction Hashes
Store Transaction Hashes
Keep permanent records of all payments:
Show Transaction Proofs to Users
Show Transaction Proofs to Users
Always display blockchain proof:
Handle Pre-Deployed Wallets
Handle Pre-Deployed Wallets
Support both pre-deployed and deployed wallets:
Implement Idempotency
Implement Idempotency
Use nonces to prevent duplicate payments:
Monitoring & Debugging
Log Payment Events
Track Revenue
Monitor Failed Payments
Next Steps
x402 Protocol
Learn the HTTP payment protocol
A2A Payments
Build agent-to-agent systems
Smart Wallets
Deep dive into wallet features
Build Your Own
Create your first payment flow