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.
The facilitator collects a $0.01 fee per settlement from your USDC balance via transferFromBEFORE executing the customer payment. This requires one-time approval.Technical details:
// You approve facilitator treasury (one-time)USDC.approve(treasury, 100 * 10^6); // 100 USDC// Before each settlement, facilitator collects fee FIRSTUSDC.transferFrom(merchant, treasury, 0.01 * 10^6); // $0.01// Then (and only then) executes settlementtransferWithAuthorization(...);
📍 Base Sepolia Merchant: 0xA821f428Ef8cC9f54A9915336A82220853059090 Treasury: 0x5D791e3554D0e83f171126905Bda1640Bf6f9A8B💰 Approving 100 USDC for pre-settlement fee collection... ⚠️ Fee will be collected BEFORE each settlement Transaction: 0x123...✅ Approval successful! Allowance: 100.0 USDC Settlements: ~10000 Note: $0.01 collected BEFORE each settlement execution
Merchant impact: Paid $0.01 for the settlement attempt.
Customer impact: Never charged.Why this is fair: Merchant received verification and settlement attempt services. Pre-settlement prevents free service exploitation.
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.
Pre-settlement means settlements fail immediately when allowance depleted - good for you and customers.
Test on Sepolia First
Always test on testnet before mainnet:
# 1. Approve on SepoliaNETWORK=sepolia node approve-facilitator.mjs# 2. Test pre-settlement flownpm run test# 3. Verify fee collected BEFORE settlement# Check transaction timestamps on BaseScan# 4. Then approve on mainnetNETWORK=mainnet node approve-facilitator.mjs
Maintain USDC Balance
Ensure sufficient USDC for fees:
Minimum: Match your allowance
Recommended: 2x allowance (safety buffer)
Pre-settlement requirement: You need actual USDC balance, not just approval. Fee is collected BEFORE settlement executes.
Monitor Failed Settlements
Track settlement success rate:
const successRate = successful_settlements / total_attempts;// If low, investigate:// - Expired authorizations// - Invalid signatures// - Network issues// Remember: With pre-settlement, you pay for attempts
The facilitator collects a $0.01 fee per settlement from your USDC balance via transferFromBEFORE 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?
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?
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?
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?
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?
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?
Yes! Every fee collection is a blockchain transaction:
# View pre-settlement fee collectionhttps://basescan.org/tx/{fee_tx_hash}# View settlement (executed after fee)https://basescan.org/tx/{settlement_tx_hash}# Verify timing: fee_tx before settlement_tx
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.