An asynchronous Python static file server with x402 paywall support. Gate access to static files behind cryptocurrency micropayments using the HTTP 402 protocol.
- Static file serving via Starlette/uvicorn
- x402 paywall on configurable routes with per-route pricing
- Supports all x402 crypto networks (EVM and Solana), one active at a time
- Separate IPv4 and IPv6 listener configuration
- TOML configuration
- Python 3.11+
- uv
# Install dependencies
uv sync
# Copy and edit the example config
cp x402d.toml.example x402d.toml
# Edit x402d.toml — set pay_to to your receiving address
# Create a document root with some content
mkdir -p public
echo "<h1>Hello</h1>" > public/index.html
# Start the server
uv run x402dThe server listens on 0.0.0.0:8402 by default.
x402d is configured via a TOML file (default: x402d.toml). See x402d.toml.example for all options.
[server]
document_root = "./public"
[server.ipv4]
enabled = true
host = "0.0.0.0"
port = 8402
[server.ipv6]
enabled = false
host = "::"
port = 8402
[x402]
facilitator_url = "https://x402.org/facilitator"
network = "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"
pay_to = "YourReceivingAddress"
[[x402.routes]]
path = "/premium/*"
price = "$0.01"
[[x402.routes]]
path = "/reports/annual.pdf"
price = "$1.00"
pay_to = "DifferentAddress"| Network | Identifier | Type |
|---|---|---|
| Base | eip155:8453 |
mainnet |
| Base Sepolia | eip155:84532 |
testnet |
| Polygon | eip155:137 |
mainnet |
| Ethereum | eip155:1 |
mainnet |
| Arbitrum One | eip155:42161 |
mainnet |
| Optimism | eip155:10 |
mainnet |
| Solana | solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp |
mainnet |
| Solana Devnet | solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1 |
testnet |
Only one network is active at a time. Default: Solana Devnet.
# Default config path
uv run x402d
# Custom config path
uv run x402d --config /path/to/x402d.toml
# Or via python -m
uv run python -m x402d# Install with dev dependencies
uv sync
# Run tests
uv run pytest tests/ -vMIT