One-line x402 pay-per-request protection for ElysiaJS APIs
One-line x402 pay-per-request protection for ElysiaJS APIs
Hi HN — I’m sharing @codingstark/x402-elysia, an ElysiaJS (Bun) plugin that implements the x402 Payment Protocol to protect HTTP routes behind crypto micropayments. What it does: Lets you configure paid routes like "GET /api/weather" and enforce payment requirements (price, chain/network, recipient address). If a client hits a protected route without a valid payment header, it returns 402 Payment Required describing what to pay; after payment, the request is allowed through and the handler runs. Why I built it: I wanted “pay-per-request” APIs in the Bun/Elysia ecosystem (same idea as existing x402 middleware in other frameworks, but native to Elysia). I’m planning to use it to power paid endpoints in my own product (slaab.ai), but this repo is intended to be generally useful for any paid API. How to try it: Install: bun add @codingstark/x402-elysia The README has a complete “Quick Start” showing .use(paymentMiddlewareFromConfig(...)). Demo: I also recorded a short video showing the flow (request → 402 → pay → retry → success): https://x.com/twitter/status/2027014126648672438 Feedback I’m looking for: Does the configuration shape feel idiomatic for Elysia apps? Any missing use-cases (multiple chains, paywall UX, internal bypass hooks) you’d want for production paid APIs?
Share cardActual performance
Launch Intel predictions
Analyze your own launch →Correct prediction on native model
Similar products
Sparkhub – Pay APIs per-request, no subscriptions
ssrfproxy.com – Server Side Request Forgery Protection
Price protection on airfare. If fares go up, we pay you.
request_migrations – request and response migrations for Rails APIs
Moover: request a move
Behavioural Experiment – Request for Participation
Slippage Protection
ZkSafeZones – Civilian Protection in Conflict Areas
b2v.xyz – Protection against impersonation attacks
B2V – Protection against impersonation attacks