On

One-line x402 pay-per-request protection for ElysiaJS APIs

Hacker News

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 card

Actual performance

1points
Did not reach leaderboard

Launch Intel predictions

Analyze your own launch →
Indie HackersFits the IH revenue-focused audience · Missing: supports, reddit linkedin, podcasting
89%89% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
best fitHighest predicted score across all platforms for this description.
Product HuntOn track for Day 1 leaderboard · Strong signals: apps, coding, apis · Missing: mac, agents, macos
77%77% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
Hacker NewsMay not resonate with HN audience · Strong signals: exist, existing, ide · Missing: https docs, excited, just released
25%25% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
TrustMRRLess likely to generate early MRR · Strong signals: apps, video · Missing: mobile apps, ios, personal
24%24% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
AppSumoMay struggle as an AppSumo deal · Missing: plus, platform, intuitive
20%20% predicted probability of success on AppSumo, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Missing: arr, mrr, revenue
18%18% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Strong signals: crypto, paid · Missing: web3, chat, cryptocurrency
0%0% predicted probability of success on BetaList, based on ML models trained on real launch data.

Correct prediction on native model

Similar products

Sp
Sparkhub – Pay APIs per-request, no subscriptions52%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Sparkhub – Pay APIs per-request, no subscriptions

Hacker News1
ss
ssrfproxy.com – Server Side Request Forgery Protection67%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

ssrfproxy.com – Server Side Request Forgery Protection

Hacker News2
Pr
Price protection on airfare. If fares go up, we pay you.59%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Price protection on airfare. If fares go up, we pay you.

Hacker News6
re
request_migrations – request and response migrations for Rails APIs28%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

request_migrations – request and response migrations for Rails APIs

Hacker News6
Mo
Moover: request a move34%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Moover: request a move

Hacker News4
Be
Behavioural Experiment – Request for Participation32%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Behavioural Experiment – Request for Participation

Hacker News1
Sl
Slippage Protection44%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Slippage Protection

Hacker News1
Zk
ZkSafeZones – Civilian Protection in Conflict Areas66%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

ZkSafeZones – Civilian Protection in Conflict Areas

Hacker News1
b2
b2v.xyz – Protection against impersonation attacks44%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

b2v.xyz – Protection against impersonation attacks

Hacker News8
B2
B2V – Protection against impersonation attacks37%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

B2V – Protection against impersonation attacks

Hacker News3