Overview
0xmeta supports both x402 v1 (legacy) and x402 v2 (current) protocols with pre-settlement fee collection to maintain trust-minimization and prevent free service exploitation.Trust-Minimized with Pre-Settlement: Customer payments go DIRECTLY to your address. The $0.01 fee is collected from your pre-approved USDC balance BEFORE the settlement executes. If fee collection fails, settlement is blocked and customer is never charged.
Quick Start
Prerequisites
- Merchant wallet with USDC on Base
- Approve facilitator for USDC spending (one-time setup)
- x402 express middleware installed
Three-Step Setup
Approve Facilitator
Payment Flow
Key Points:- ✅ Facilitator collects $0.01 fee from merchant FIRST (pre-settlement)
- ✅ Then executes customer → merchant payment ($0.02)
- ✅ Client pays DIRECTLY to merchant (no facilitator custody)
- ✅ Merchant receives 100% of customer payment
- ⚠️ If fee collection fails, settlement is blocked (customer not charged)
x402 v2 Integration (Recommended)
Installation
Complete Server Example
x402 v1 Integration (Legacy)
Installation
Complete Server Example
Merchant Approval Setup
Why Approval Is Required
The facilitator collects a $0.01 fee per settlement from your USDC balance viatransferFrom BEFORE executing the customer payment. This requires one-time approval.
Technical details:
approve-facilitator.mjs
Monitoring Allowance
check-allowance.mjs
Network Configuration
Base Sepolia (Testnet)
| Resource | Value |
|---|---|
| Chain ID | 84532 |
| CAIP-2 | eip155:84532 |
| USDC | 0x036CbD53842c5426634e7929541eC2318f3dCF7e |
| Treasury | 0x5D791e3554D0e83f171126905Bda1640Bf6f9A8B |
| RPC | https://sepolia.base.org |
Base Mainnet (Production)
| Resource | Value |
|---|---|
| Chain ID | 8453 |
| CAIP-2 | eip155:8453 |
| USDC | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 |
| Treasury | 0x5D791e3554D0e83f171126905Bda1640Bf6f9A8B |
| RPC | https://mainnet.base.org |
Error Handling
Insufficient Allowance (Pre-Settlement)
If merchant hasn’t approved facilitator:Fee Collection Failed (Pre-Settlement)
If merchant has insufficient USDC balance:Settlement Failed (After Pre-Settlement Fee)
If settlement fails AFTER fee was collected:Best Practices
Approve Reasonable Amounts
Approve Reasonable Amounts
Recommended: 100-1000 USDC (10,000-100,000 settlements)Avoid: Infinite approval (max uint256)Why: Limits exposure if facilitator compromised. Pre-settlement means fees are collected before settlement, so your risk is limited to the approved amount.
Monitor Allowance Regularly
Monitor Allowance Regularly
Set up automated checks:Pre-settlement means settlements fail immediately when allowance depleted - good for you and customers.
Test on Sepolia First
Test on Sepolia First
Always test on testnet before mainnet:
Maintain USDC Balance
Maintain USDC Balance
Ensure sufficient USDC for fees:
- Minimum: Match your allowance
- Recommended: 2x allowance (safety buffer)
Monitor Failed Settlements
Monitor Failed Settlements
Track settlement success rate:
FAQ
Why do I need to approve the facilitator?
Why do I need to approve the facilitator?
The facilitator collects a $0.01 fee per settlement from your USDC balance via
transferFrom BEFORE executing the customer payment. This is a standard ERC-20 pattern that requires approval.Pre-settlement means: Fee must be collectible before settlement can execute.Can the facilitator access all my USDC?
Can the facilitator access all my USDC?
No. Only the approved amount is accessible. Pre-settlement doesn’t change this.Approve 100 USDC → max risk is 100 USDC.
What if I revoke approval?
What if I revoke approval?
Future settlements will fail at the pre-settlement fee collection step with
insufficient_allowance error. Customers won’t be charged because settlement never executes.Why not collect fee from customer?
Why not collect fee from customer?
x402 requires customer payments go directly to merchants (trust-minimization). We can’t split customer payments, so merchants pay the fee separately via pre-settlement collection.
What happens if settlement fails after fee?
What happens if settlement fails after fee?
You paid $0.01 for the settlement attempt. This prevents free service exploitation.Pre-settlement rationale: Without collecting fee first, merchants could intentionally fail settlements for free verification service.
How does pre-settlement protect customers?
How does pre-settlement protect customers?
If your fee collection fails (insufficient allowance or balance), settlement NEVER executes. Customer is never charged.Order: Fee collection → Settlement executionNo fee = no settlement = customer safe.
Can I see pre-settlement on-chain?
Can I see pre-settlement on-chain?
Yes! Every fee collection is a blockchain transaction:
Next Steps
Architecture
Understand pre-settlement payment flow
API Reference
Explore endpoints
Pricing
Pre-settlement fee structure details
FAQ
Common questions about pre-settlement
You’re ready! Approve the facilitator for pre-settlement fee collection, configure your server with YOUR merchant address, and start accepting payments.Remember: Fee is collected BEFORE settlement. If fee collection fails, settlement is blocked and customer is never charged. This protects customers and prevents free service exploitation.