Overview
This guide walks you through setting up your merchant account to accept x402 payments via 0xmeta facilitator with pre-settlement fee collection.Trust-Minimized: Customer payments go directly to your address. The facilitator collects a $0.01 fee from your pre-approved USDC balance after each settlement.
Prerequisites
1
Merchant Wallet
An Ethereum wallet address where you’ll receive customer payments
2
Private Key Access
Access to the wallet’s private key (for one-time USDC approval)
3
Base Network Assets
- ETH: ~0.001 ETH for approval transaction gas
- USDC: ~100 USDC for fees (covers ~10,000 settlements)
4
Network Selection
Choose Base Mainnet (production) or Base Sepolia (testing)
Step 1: Get Testnet Assets (For Testing)
If testing on Base Sepolia first (recommended):Get Base Sepolia ETH
Visit the Coinbase faucet:- Connect your merchant wallet
- Request 0.05 ETH (free, once per 24 hours)
- Wait ~30 seconds for confirmation
Get Base Sepolia USDC
Visit the Circle faucet:- Select “Base Sepolia”
- Enter your merchant address
- Request 10 USDC
- Wait ~1 minute for confirmation
Verify you received the tokens on BaseScan
Sepolia
Step 2: Approve USDC Spending
This is the only required setup step. You must approve 0xmeta’s treasury to collect the $0.01 fee per settlement from your USDC balance.Why Approval Is Required
The facilitator uses standard ERC-20transferFrom to collect fees:
- ✅ Customers pay YOU directly
- ✅ Facilitator collects fee from YOUR approved balance
- ✅ No facilitator custody of customer funds
Option A: Using Our Setup Script (Recommended)
1. Install dependencies:Option B: Manual Approval (via Etherscan)
1. Visit Base USDC contract: Sepolia:approve function:
- spender:
0x5D791e3554D0e83f171126905Bda1640Bf6f9A8B(Treasury) - amount:
100000000(100 USDC with 6 decimals)
Step 3: Verify Setup
Check that approval was successful:Step 4: Integrate x402 Middleware
Now you’re ready to accept payments! Choose your x402 version:Option A: x402 v2 (Recommended)
Option B: x402 v1 (Legacy)
Step 5: Test Payment Flow
1. Start Your Server
2. Test with x402 Client
Create a test client (or use our example):3. Expected Flow
Success! If you see the premium content, your integration is working.
Step 6: Monitor Allowance
Set up regular monitoring to ensure you don’t run out of approved funds:Manual Check
Automated Monitoring
Option 1: Cron jobStep 7: Production Deployment
When ready for production:Switch to Base Mainnet
1. Update configuration:Production Checklist
1
Approval Confirmed
- Approved ≥ 100 USDC on mainnet
- Verified via check-allowance.mjs
2
Testing Complete
- Tested full payment flow on Sepolia
- Verified customer payments received
- Confirmed fee collection working
3
Monitoring Setup
- Automated allowance checks configured
- Alerts for low balance set up
- Settlement logging in place
4
Security
- Private keys secured (not in code)
- .env file in .gitignore
- Reasonable approval amount (not infinite)
Network Information
Base Sepolia (Testnet)
Base Mainnet (Production)
Troubleshooting
Approval transaction fails
Approval transaction fails
Causes:
- Insufficient ETH for gas
- Wrong network selected
- Invalid treasury address
- Check ETH balance: Must have ~0.001 ETH
- Verify you’re on correct network
- Double-check treasury address:
0x5D791e3554D0e83f171126905Bda1640Bf6f9A8B
Settlement fails with 'insufficient_allowance'
Settlement fails with 'insufficient_allowance'
Cause: Approval wasn’t successful or depletedSolution:
Can't connect to RPC
Can't connect to RPC
Cause: Network issues or RPC rate limitingSolution:
- Wait a few minutes and try again
- Use custom RPC (Alchemy, Infura, QuickNode)
- Check Base network status
Customer payments not arriving
Customer payments not arriving
Cause: Wrong address in payToSolution:
Verify
payTo uses YOUR merchant address (not treasury):Script References
Approval Script Reference
Save asapprove-facilitator.mjs:
Monitoring Script Reference
Save ascheck-allowance.mjs:
Next Steps
x402 Integration
Complete integration guide
Architecture
Understand payment flow
API Reference
Explore endpoints
FAQ
Common questions
You’re all set! Start accepting x402 payments with pre-settlement fee collection.