Skip to main content

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

  1. Merchant wallet with USDC on Base
  2. Approve facilitator for USDC spending (one-time setup)
  3. x402 express middleware installed

Three-Step Setup

1

Approve Facilitator

Approves facilitator treasury to collect $0.01 fees from your USDC balance BEFORE each settlement.
2

Configure Server

3

Start Accepting Payments

Facilitator collects fee FIRST, then executes customer → merchant payment.

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)

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 via transferFrom BEFORE executing the customer payment. This requires one-time approval. Technical details:

approve-facilitator.mjs

Expected Output:

Monitoring Allowance

check-allowance.mjs

Expected Output:

Network Configuration

Base Sepolia (Testnet)

Base Mainnet (Production)


Error Handling

Insufficient Allowance (Pre-Settlement)

If merchant hasn’t approved facilitator:
Solution:
Customer impact: None - they are never charged when pre-settlement fee collection fails.

Fee Collection Failed (Pre-Settlement)

If merchant has insufficient USDC balance:
Solution: Add USDC to merchant address. Customer impact: None - settlement never executes if pre-settlement fee collection fails.

Settlement Failed (After Pre-Settlement Fee)

If settlement fails AFTER fee was collected:
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.

Best Practices

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.
Set up automated checks:
Pre-settlement means settlements fail immediately when allowance depleted - good for you and customers.
Always test on testnet before mainnet:
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.
Track settlement success rate:

FAQ

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.
No. Only the approved amount is accessible. Pre-settlement doesn’t change this.Approve 100 USDC → max risk is 100 USDC.
Future settlements will fail at the pre-settlement fee collection step with insufficient_allowance error. Customers won’t be charged because settlement never executes.
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.
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.
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.
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.