Back to browse
GitHub Repository

ElysiaJS plugin for the x402 Payment Protocol. Protect any route behind a crypto micropayment with a single .use() call.

1 starsTypeScript

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

by codingstark·Feb 26, 2026·1 point·0 comments

AI Analysis

MidShip ItBold Bet

One-liner x402 middleware for ElysiaJS; niche stack, nascent payment protocol adoption.

Strengths
  • Elegant one-liner API reduces boilerplate for payment-gating routes in ElysiaJS.
  • Implements open x402 standard; facilitator abstraction allows plugging alternate payment schemes.
  • Author has real use case (slaab.ai) so dog-fooding validates the approach.
Weaknesses
  • x402 payment protocol has minimal adoption; ecosystem maturity unclear beyond Coinbase's facilitator.
  • Requires Bun/ElysiaJS; misses broader audience (Node.js, Python, Go developers).
  • No evidence of security audit or production usage at scale.
Target Audience

Bun/ElysiaJS developers building paid APIs or SaaS with crypto payments

Similar To

Stripe Billing · Lemonsqueezy · Gumroad

Post Description

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?

Similar Projects

Developer Tools●●Solid

X402 Agent Starter Kit: AI agents that pay for their own APIs

They revive HTTP 402 so agents can automatically buy API calls — the repo ships PayingClient/WalletManager primitives, an @x402-kit/core package, five agent templates (web-scraper, image-gen, search, translation, code-review), a live demo and 93 tests. Smart infrastructure play with a clear demoable surface; the hard part will be UX and economics (wallet funding, gas/settlement, and convincing API operators to adopt x402 instead of existing billing).

Bold BetBig BrainShip It
peiyaooo
353mo ago
AI/ML●●●Banger

MCP plugin that lets Claude autonomously pay for APIs via Lightning

Agents finally have bank accounts: 402 interception + Lightning payments just works.

Zero to OneBold BetBig Brain
jaafarskafi
102mo ago