Overview
The EVM payment handler implements theexact scheme for x402-exact payments on Ethereum Virtual Machine (EVM) compatible networks. It uses EIP-3009 transferWithAuthorization where clients sign off-chain authorizations and the facilitator executes the on-chain transfer.
Supported Networks
- base-sepolia - Base Sepolia Testnet
- base - Base Mainnet
- Additional networks supported via EIP-155 format (e.g.,
eip155:137for Polygon)
Payment Mechanism
EIP-3009 Transfer Authorization
EIP-3009 allows users to authorize token transfers via signed messages instead of direct transactions:- Client signs authorization: Creates an off-chain EIP-712 signature authorizing the transfer
- Facilitator executes: Calls
transferWithAuthorizationon the token contract - Facilitator pays gas: The facilitator’s wallet pays transaction fees
- Transfer executes: Token contract validates signature and executes transfer
EIP-712 Typed Data
The authorization uses EIP-712 structured data signing for security:Requirements Enrichment
When a resource server calls/accepts, the EVM handler adds these fields to the extra object:
EIP-712 domain name (token name).Example:
"USDC"EIP-712 domain version.Example:
"2"Chain identifier for the network.Example:
84532 for Base SepoliaToken contract address (or forwarder contract address if using EIP-3009 forwarding) for EIP-712 verification.Example:
"0x036CbD53842c5426634e7929541eC2318f3dCF7e" (USDC on Base Sepolia)Settlement Validation
When processing a/settle request, the EVM handler performs these checks:
1. Signature Verification
Verifies the EIP-712 signature matches the authorization:2. Amount Validation
Ensures the authorized amount matches requirements:3. Recipient Validation
Verifies the recipient is the merchant:4. Time Validity
Checks authorization is within its valid time window:5. Nonce Check
Verifies the nonce hasn’t been used (on-chain check):Transaction Execution
After validation, the facilitator:- Calls token contract: Executes
transferWithAuthorization - Pays gas: Facilitator wallet covers transaction fees
- Waits for confirmation: Polls for transaction receipt
- Returns result: Provides transaction hash
Token Support
The EVM handler supports EIP-3009 compatible tokens:- USDC: Native
transferWithAuthorizationsupport on all chains - Custom tokens: Any ERC-20 token with EIP-3009 support
Not all ERC-20 tokens support EIP-3009. Check token contract documentation.
Gas Sponsorship
The facilitator wallet must:- Hold sufficient native currency (ETH, ETH on Base, etc.) for gas
- Pay gas for each
transferWithAuthorizationcall - Monitor gas prices to avoid excessive costs
Error Scenarios
Common errors during EVM payment processing:| Error | Cause | Solution |
|---|---|---|
| Invalid signature | Signature doesn’t match authorization data | Verify EIP-712 domain and message match exactly |
| Invalid transfer amount | Value doesn’t match requirements | Check amount uses token’s smallest units |
| Invalid recipient address | to field doesn’t match merchant | Verify payTo from requirements |
| Authorization expired | Current time > validBefore | Create new authorization with fresh timestamp |
| Nonce already used | Nonce was used in previous transaction | Generate new random nonce |
| Insufficient allowance | Token balance too low | Client needs sufficient token balance |