x402-anychain
v0.1.29
Published
Self-hosted x402 facilitator for ANY EVM chain. Add a chain by adding an RPC. First-class support for yield-bearing (NAV-up) settlement assets.
Maintainers
Readme
x402-anychain
Self-hosted, multi-chain x402 facilitator. Holds gas, never funds.
Unaudited.
Why
The CDP facilitator settles 5 networks. This one settles 22 — every EVM chain
PublicNode serves — because /verify and /settle are chain-agnostic: both EVM
transfer paths (EIP-3009, Permit2) are signature-based, so one adapter serves
every eip155:*. Adding a chain is an RPC URL and a funded signer, not new code.
npm i -g x402-anychain
x402-anychain gas # exactly what to fund, and where
x402-anychain serveOne address, every chain
An EVM address derives from the key alone, not the chain. So X402_SIGNER_KEY
yields the same address on all 22 — funding is one address topped up per
chain, not a matrix of accounts. The signer holds only gas; it can never touch
a payment.
Two things most facilitators get wrong
1. A percentage fee cannot cover a flat cost. Sponsoring gas costs the same
at any payment size. Measured on Robinhood Chain, settlement is ~$0.011 — so a
1bps fee only breaks even at a $110 payment. /quote returns a flat
gas × margin fee and the minimum viable payment per chain.
2. Sub-dollar payments need batching.
| batch | gas/payment | break-even payment | |---|---|---| | 1 | $0.01105 | $110.50 | | 100 | $0.0001105 | $1.11 | | 1000 | $0.0000111 | $0.11 |
Each queued payment stays an independent EIP-3009 signature — nothing is netted or trusted, and a failure drops one authorization, not the batch.
Fee-on-transfer and yield-bearing assets
/verify checks what the payee receives, not what the payer signed. On a
taxed asset those differ, and verifying the signed amount attests to money that
never arrived. Resource servers gross up at quote time via grossUpFor; the
payee gets exactly what it asked for and the tax still accrues.
Rebasing tokens are unsupported by construction: the payer signs an exact smallest-unit amount, so a balance that moves before settlement invalidates it. NAV-up wrappers are fine.
Discovery
Agents don't shop for facilitators — they obey whatever a 402 names. So ship services and index them:
GET /discovery/resources(and/list) — our own Bazaar; the spec is openGET /.well-known/x402.json— static manifest for crawlersPOST /discovery/register— add a resource
Resources this facilitator has actually settled are marked verified.
Stats agents can recompute
/stats and /historicalStats compute trailing yield live from archive
state and ship the block range and method with every number. NAV growth is
reported alongside totalAssets, because NAV alone rises when supply burns —
which is redistribution, not earnings, and the caveats say so.
MIT.
