How to accept multi-token x402 payments on your own endpoints using the Silverback Facilitator.
Overview
If you run an API and want to charge per-request using x402, the Silverback Facilitator handles all the payment complexity for you. You just need to:
Return the right 402 response when a client hasn't paid
Point to the Silverback Facilitator as your payment processor
Choose which tokens you want to accept
The facilitator handles signature verification, on-chain settlement, fee splitting, and transaction confirmation. You focus on your API.
What You Need
A wallet address on Base to receive payments
An Express.js server (or any HTTP server)
The @x402/express package (or build your own 402 responses)
Step 1: Install Dependencies
Step 2: Configure Your Server
Set these environment variables:
Step 3: Set Up Payment Middleware
Option A: Using the x402 Express Package
Option B: Build Your Own 402 Response
If you're not using Express or want full control, return an HTTP 402 response with the payment-required header:
Step 4: Build Your Payment Options
The accepts array in your 402 response tells clients which tokens you accept. Each entry is one payment option.
Accept Only USDC (Simplest)
Accept Multiple Tokens
To accept more tokens, add additional entries to the accepts array. Each token needs its amount converted from USD at the current market rate.
Use the Facilitator's Price API
Instead of fetching prices yourself, use the facilitator's built-in converter:
Step 5: Using the Fee Splitter (Optional)
If you want Silverback to handle fee splitting automatically, point payTo to the Fee Splitter contract instead of your own wallet. The fee splitter takes a small percentage and forwards the rest to your wallet.
Fee rates:
$BACK: 0% (fee-exempt)
Stablecoins (USDC, USDT, DAI): 0.1%
Ecosystem tokens (VIRTUAL): 0.1%
Blue-chip assets (WETH, cbBTC): 0.25%
Step 6: Register in the Discovery Bazaar (Optional)
Make your endpoints discoverable by other agents and clients through the Silverback Bazaar.
The facilitator's discovery service at /discovery/resources lets clients browse available x402 endpoints. To register your endpoints, publish a resource description that includes:
Discovery endpoints on the facilitator:
GET /discovery/resources — Browse all registered endpoints
GET /discovery/categories — List categories (defi, trading, analytics, etc.)
GET /discovery/tags — List all tags
GET /discovery/info — Service metadata
Important Rules
Amount Conversion
Amounts in the accepts array must be in base units (smallest denomination), not human-readable amounts:
Token
Decimals
$0.01 in base units
USDC
6
10000
USDT
6
10000
DAI
18
10000000000000000
WETH (at $2,100)
18
4761904761904
cbBTC (at $70,000)
8
14
BACK (at $0.00008)
18
100000000000000000000
Getting decimals wrong is the most common integration mistake.
Cache Control
Always set Cache-Control: no-store, no-cache, must-revalidate, private on 402 responses. Without this, CDNs may cache the payment options and serve stale prices.
Timeout
Set maxTimeoutSeconds: 300 (5 minutes) in each payment option. This gives clients enough time to sign and submit payment without the authorization expiring.
x402 Version
Always set x402Version: 2 in your 402 response. Version 2 supports both ERC-3009 (USDC) and Permit2 (all other tokens).
How the Client Pays
You don't need to implement this — the x402 SDK handles it automatically on the client side. But for reference:
Client receives your 402 response
SDK picks a token the client has sufficient balance for
USDC — SDK signs an ERC-3009 transferWithAuthorization (no prior approval needed)
Any other token — SDK signs a Permit2 permitWitnessTransferFrom (requires one-time Permit2 approval)
SDK sends the signed payment to the facilitator for verification
Facilitator confirms the payment is valid
SDK re-sends the original request with the payment proof in the PAYMENT-SIGNATURE header
Your server receives the request, facilitator settles on-chain, and you serve the response
What You Handle vs What the Facilitator Handles
You (the seller)
Silverback Facilitator
Return 402 with accepts array
Verify payment signatures
Set prices in USD
Convert USD to token amounts
Choose which tokens to accept
Settle payments on-chain
Serve your API response
Split fees automatically
Keep token prices updated
Manage Permit2 and ERC-3009
Provide discovery/bazaar
Handle transaction confirmations
Testing
On Testnet (Base Sepolia)
Use network: 'eip155:84532' in your accepts array and test with Sepolia tokens.
On Mainnet
Start with low-value endpoints ($0.001) and test with the x402 SDK:
Verify Facilitator Connectivity
Troubleshooting
Problem
Solution
Client gets 402 but can't pay
Check accepts array format — amounts must be strings in base units
Payment fails with "unsupported token"
Token must be on the facilitator's whitelist (check /supported/tokens)
import { wrapFetchWithPaymentFromConfig } from '@x402/fetch';
import { ExactEvmScheme } from '@x402/evm/exact/client';
const fetchWithPayment = wrapFetchWithPaymentFromConfig(fetch, {
schemes: [{
x402Version: 2,
network: 'eip155:8453',
client: new ExactEvmScheme(yourWalletSigner)
}]
});
const res = await fetchWithPayment('https://your-server.com/api/v1/my-endpoint');
console.log(await res.json());
# Check the facilitator is reachable
curl https://facilitator.silverbackdefi.app/health
# Check supported tokens and current prices
curl https://facilitator.silverbackdefi.app/supported/tokens
# Test price conversion
curl "https://facilitator.silverbackdefi.app/supported/convert?usd=0.01&token=BACK"