Skip to main content

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-20 transferFrom to collect fees:
This is how the facilitator maintains x402 trust-minimization:
  • ✅ Customers pay YOU directly
  • ✅ Facilitator collects fee from YOUR approved balance
  • ✅ No facilitator custody of customer funds
1. Install dependencies:
2. Configure environment:
3. Run approval:
Expected output:
Script source: See approve-facilitator.mjs

Option B: Manual Approval (via Etherscan)

1. Visit Base USDC contract: Sepolia:
Mainnet:
2. Connect your wallet 3. Call approve function:
  • spender: 0x5D791e3554D0e83f171126905Bda1640Bf6f9A8B (Treasury)
  • amount: 100000000 (100 USDC with 6 decimals)
4. Confirm transaction
Approval amount = settlements × $0.01Example: 100 USDC approval = 10,000 settlements

Step 3: Verify Setup

Check that approval was successful:
Expected output:
Script source: See check-allowance.mjs

Step 4: Integrate x402 Middleware

Now you’re ready to accept payments! Choose your x402 version:

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 job
Option 2: Application monitoring

Step 7: Production Deployment

When ready for production:

Switch to Base Mainnet

1. Update configuration:
2. Run approval on mainnet:
3. Update environment:

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

Causes:
  • Insufficient ETH for gas
  • Wrong network selected
  • Invalid treasury address
Solution:
  • Check ETH balance: Must have ~0.001 ETH
  • Verify you’re on correct network
  • Double-check treasury address: 0x5D791e3554D0e83f171126905Bda1640Bf6f9A8B
Cause: Approval wasn’t successful or depletedSolution:
Cause: Network issues or RPC rate limitingSolution:
  • Wait a few minutes and try again
  • Use custom RPC (Alchemy, Infura, QuickNode)
  • Check Base network status
Cause: Wrong address in payToSolution: Verify payTo uses YOUR merchant address (not treasury):

Script References

Approval Script Reference

Save as approve-facilitator.mjs:

Monitoring Script Reference

Save as check-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.