x402 but without centralized stuff

smol402

x402, but actually decentralized.

Trustless x402 payment protocol using pypolkadot light clients. No facilitators, no RPC providers, no middlemen.

Why?

x402 (original) smol402
Verification Facilitator service Local light client
Dependencies Third party server uptime None
Censorship Facilitator can block Unstoppable
Trust RPC provider Cryptographic proofs

How It Works

  1. Client requests resource → Server returns 402 with payment address/amount
  2. Client submits payment on-chain, waits for finalization
  3. Client retries with X-Payment: block=0x... header
  4. Server verifies payment via embedded light client
  5. Server returns resource

tldr:

Key insight: Server only queries chain when buyer provides proof. No background listeners needed.

Installation

pip install -r requirements.txt

Or use uv, of course.

Start

python server_simple.py # (simple)
python server_cookie.py # (with persistence and session tokens for paiments)

Client Usage (simple)

# 1. Request (get 402)
curl -i http://localhost:5402/premium

# Call curl http://localhost:5402/health once to warm up light client

# 2. Make payment on Paseo Asset Hub
#    - Use polkadot.js/apps or any wallet
#    - Send to the recipient address
#    - Wait for finalization, note the block hash

# 3. Retry with proof
curl http://localhost:5402/premium \
  -H "X-Payment: block=0xYOUR_BLOCK_HASH"

Client Usage (cookie)

# 1. Request (get 402 + session cookie)
curl -i -c cookies.txt http://localhost:5402/premium

# Call curl http://localhost:5402/health once to warm up light client

# 2. Make payment on Paseo Asset Hub
#    - Use polkadot.js/apps or any wallet
#    - Send to the recipient address
#    - Wait for finalization, note the block hash

# 3. Retry with proof + cookie
curl -i -b cookies.txt http://localhost:5402/premium \
    -H "X-Payment: block=0xYOUR_BLOCK_HASH"

Supported Networks

Features

How It Compares

Feature x402 smol402
Needs facilitator
Self-hostable Partial ✅ Fully
Censorship resistant
Light client verification

License

GPL3

Credits