Menu

Two HTTP payment rails, one API: how I charge agents per call with x402 and L402
πŸ“°

Two HTTP payment rails, one API: how I charge agents per call with x402 and L402

DEV Community: backendΒ·int devΒ·1 day ago
#ShQoJNwy
#devtobackend#devto#dev#l402#agents
Reading 0:00
15s threshold

Last week I shipped AtlasData , a pay-per-call crypto data API where the buyer is usually not a human β€” it is an agent that holds a wallet. Getting paid per request without accounts, API keys, or invoices meant implementing both of the protocols that actually work today: x402 (USDC on Base) and L402 (Lightning sats). Here is what I learned running both on the same FastAPI app.

The shape of both protocols

Both live on HTTP 402 Payment Required:

curl -i https://atlasdata.shares.zrok.io/api/price/BTC # HTTP/2 402 # {"payment": {"maxAmountRequired":"1000", "asset":"USDC", "network":"eip155:8453", ...}}

curl -i https://atlasdata.shares.zrok.io/l402/btc/fees # HTTP/2 402 # www-authenticate: L402 macaroon="...", invoice="lnbc100n1..."

Enter fullscreen mode

Exit fullscreen mode

The difference is the proof. x402 returns an EIP-3009 transferWithAuthorization the client signs; a facilitator settles it onchain, then your server serves the response.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.