x402 Advanced Facilitator Examples (Python)
FastAPI facilitator service demonstrating advanced x402 patterns including all-networks support, bazaar discovery, and lifecycle hooks across EVM, SVM, and TVM.
Prerequisites
- Python 3.10+
- uv (install via docs.astral.sh/uv)
- Any configured payment signer set:
- EVM private key with Base Sepolia ETH for transaction fees
- SVM private key with Solana Devnet SOL for transaction fees
- TVM private key with TON testnet funds
To fund the TVM facilitator wallet, request testnet TON from @testgiver_ton_bot. The facilitator wallet only needs TON for relay fees and must hold at least 1.1 TON before running tests.
Note: the facilitator uses a highload-wallet-v3 account, so the facilitator's wallet address differs from your W5 address — fund the highload-v3 address, not the W5 one derived from the same key.
To get testnet-USDT for the payer wallet, open the testnet USDT transfer link or scan the QR code below:
Setup
- Copy
.env-localto.env:
cp .env-local .env
- Fill required environment variables:
EVM_PRIVATE_KEY- Ethereum private keySVM_PRIVATE_KEY- Solana private keyTVM_PRIVATE_KEY- TVM private key for the facilitator walletTVM_NETWORK- TVM CAIP-2 network (optional, defaults totvm:-3)TONCENTER_API_KEY- Toncenter API key for TVM testnet (optional)TONCENTER_BASE_URL- Custom Toncenter base URL (optional)PORT- Server port (optional, defaults to 4022)
- Install dependencies:
uv sync
- Run the server:
uv run python all_networks.py # All supported networks with optional chain configuration
uv run python bazaar.py # Bazaar discovery extension
Available Examples
| Example | Command | Description |
|---|---|---|
all_networks |
uv run python all_networks.py |
All supported networks with optional chain configuration |
bazaar |
uv run python bazaar.py |
Bazaar discovery extension for cataloging x402 resources |
API Endpoints
GET /supported
Returns supported networks and schemes.
POST /verify
Verifies a payment signature.
POST /settle
Settles a verified payment by broadcasting the transaction on-chain.
Network Identifiers
Networks use CAIP-2 format:
eip155:84532— Base Sepoliaeip155:8453— Base Mainnetsolana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1— Solana Devnetsolana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp— Solana Mainnettvm:-3— TON Testnettvm:-239— TON Mainnet