ShinyDapps/l402-kit

๐Ÿ’ฐ Finance & Fintech
0 Views
0 Installs

๐Ÿ“‡ โ˜๏ธ ๐ŸŽ ๐ŸชŸ ๐Ÿง - Full-stack L402 SDK: server middleware (Express/FastAPI/axum/net/http) + agent client with auto-pay. 4 languages (TypeScript, Python, Go, Rust). MCP server, LangChain integration, budget control. npx l402-kit-mcp

Quick Install

One-Click IDE Configuration
claude_desktop_config.json
{
  "mcpServers": {
    "shinydapps-l402-kit": {
      "command": "npx",
      "args": [
        "-y",
        "shinydapps-l402-kit"
      ]
    }
  }
}
Or

Using an AI coding agent (Claude Code, Cursor, etc.)? Copy a ready-made prompt that tells it to fetch the setup instructions and install this server for you.

Documentation Overview

l402-kit

l402-kit

Add Bitcoin Lightning pay-per-call to any API. 3 lines of code.

License: MIT Live Demo Tests l402-kit MCP server


VS Code Marketplace Installs

โ–ถ Watch end-to-end demo โ€” install โ†’ 402 โ†’ pay โ†’ 200 OK



Live traction

SDKVersionDownloads
๐Ÿ“ฆ TypeScript ยท npmjs.com/package/l402-kitnpmnpm total
๐Ÿ Python ยท pypi.org/project/l402kitpypipypi total
๐Ÿฆ€ Rust ยท crates.io/crates/l402kitcratescrates dls
๐Ÿ”Œ VS Code Extension ยท marketplacevscode vermarketplace
๐Ÿฆซ Go ยท pkg.go.devgogo report


๐ŸŒ Available in 11 languages โ€” click to expand

๐Ÿ‡บ๐Ÿ‡ธ Charge for your API in Bitcoin Lightning. 3 lines of code. ๐Ÿ‡ง๐Ÿ‡ท Monetize sua API com Bitcoin Lightning. 3 linhas de cรณdigo. ๐Ÿ‡ช๐Ÿ‡ธ Monetiza tu API con Bitcoin Lightning. 3 lรญneas de cรณdigo. ๐Ÿ‡จ๐Ÿ‡ณ ็”จ 3 ่กŒไปฃ็ ๏ผŒ้€š่ฟ‡ๆฏ”็‰นๅธ้—ช็”ต็ฝ‘็ปœๆ”ถ่ดนใ€‚ ๐Ÿ‡ฎ๐Ÿ‡ณ เค…เคชเคจเฅ‡ API เค•เฅ‹ Bitcoin Lightning เคธเฅ‡ 3 เคฒเคพเค‡เคจเฅ‹เค‚ เคฎเฅ‡เค‚ เคฎเฅ‹เคจเฅ‡เคŸเคพเค‡เคœเคผ เค•เคฐเฅ‡เค‚เฅค ๐Ÿ‡ธ๐Ÿ‡ฆ ุงูƒุณุจ ู…ู† API ุงู„ุฎุงุต ุจูƒ ุนุจุฑ Bitcoin Lightning. 3 ุฃุณุทุฑ ูู‚ุท. ๐Ÿ‡ซ๐Ÿ‡ท Monรฉtisez votre API en Bitcoin Lightning. 3 lignes de code. ๐Ÿ‡ฉ๐Ÿ‡ช Monetarisiere deine API mit Bitcoin Lightning. 3 Zeilen Code. ๐Ÿ‡ท๐Ÿ‡บ ะœะพะฝะตั‚ะธะทะธั€ัƒะน ัะฒะพะน API ั‡ะตั€ะตะท Bitcoin Lightning. 3 ัั‚ั€ะพะบะธ ะบะพะดะฐ. ๐Ÿ‡ฏ๐Ÿ‡ต Bitcoin LightningใงAPIใ‚’3่กŒใงๅŽ็›ŠๅŒ–ใ€‚ ๐Ÿ‡ฎ๐Ÿ‡น Monetizza la tua API con Bitcoin Lightning. 3 righe di codice.

๐Ÿ“– Official docs: ๐Ÿ‡บ๐Ÿ‡ธ ยท ๐Ÿ‡ง๐Ÿ‡ท ยท ๐Ÿ‡ช๐Ÿ‡ธ ยท ๐Ÿ‡จ๐Ÿ‡ณ ยท ๐Ÿ‡ฎ๐Ÿ‡ณ ยท ๐Ÿ‡ธ๐Ÿ‡ฆ ยท ๐Ÿ‡ซ๐Ÿ‡ท ยท ๐Ÿ‡ฉ๐Ÿ‡ช ยท ๐Ÿ‡ท๐Ÿ‡บ ยท ๐Ÿ‡ฏ๐Ÿ‡ต ยท ๐Ÿ‡ฎ๐Ÿ‡น


Install

npm install l402-kit        # TypeScript / Node.js / Express
pip install l402kit         # Python / FastAPI / Flask
go get github.com/shinydapps/l402-kit/go@v1.10.0   # Go / net/http / Chi / Gin
cargo add l402kit           # Rust / axum

AI Agents / LLMs: See llms.txt for machine-readable instructions. Agent discovery: /.well-known/agent.json ยท /.well-known/l402.json


For AI Agents

l402-kit is the payment layer for autonomous agents. Agents can pay for APIs without human intervention.

System prompt snippet โ€” add this to any agent to enable L402 payments:

You have access to paid APIs via the L402 protocol.
When you call an API that returns HTTP 402, use the L402Client from l402-kit
to pay automatically with Bitcoin Lightning.
Budget limit: {BUDGET_SATS} sats per session. Never exceed this limit.

Agent SDK quickstart:

import { l402Client, buildWallet } from "l402-kit/agent";

const client = l402Client({
  wallet: buildWallet(process.env), // auto-detects BLINK_API_KEY or ALBY_TOKEN
  budgetSats: 1000,
});

const data = await client.fetch("https://api.example.com/paid-endpoint");

MCP Server (for Claude Desktop, Cursor, and any MCP-compatible agent):

{
  "mcpServers": {
    "l402-kit": {
      "command": "npx",
      "args": ["l402-kit-mcp"],
      "env": { "BLINK_API_KEY": "your-key" }
    }
  }
}

Compatible with: LangChain ยท OpenAI Agents ยท CrewAI ยท Vercel AI SDK ยท AutoGPT ยท Any MCP client

Protocol support: L402 (Bitcoin Lightning) ยท x402 (USDC/Coinbase) compatible

Powered by L402-Kit


How it works

1. Client calls your API
       โ†“
2. API returns  HTTP 402 + BOLT11 invoice + macaroon
       โ†“
3. Client pays  (any Lightning wallet, < 1 second, any country)
       โ†“
4. Client sends Authorization: L402 <macaroon>:<preimage>
       โ†“
5. API verifies SHA256(preimage) == paymentHash  โœ“
       โ†“
6. HTTP 200 OK + your data

โ”€โ”€ Fee flow (managed mode) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   Payment โ†’ 99.7% โ†’ your Lightning Address  (instant)
           โ†’  0.3% โ†’ ShinyDapps

Quickstart

TypeScript

import express from "express";
import { l402, AlbyProvider } from "l402-kit";

const app = express();

const lightning = new AlbyProvider(process.env.ALBY_TOKEN!);

app.get("/premium", l402({ priceSats: 100, lightning }), (_req, res) => {
  res.json({ data: "Payment confirmed." });
});

app.listen(3000);

Python

from fastapi import FastAPI, Request
from l402kit import l402_required

app = FastAPI()

@app.get("/premium")
@l402_required(price_sats=100, owner_lightning_address="you@yourdomain.com")
async def premium(request: Request):
    return {"data": "Payment confirmed."}

Go

package main

import (
    "fmt"
    "net/http"
    l402kit "github.com/shinydapps/l402-kit/go"
)

func main() {
    http.Handle("/premium", l402kit.Middleware(l402kit.Options{
        PriceSats:             100,
        OwnerLightningAddress: "you@yourdomain.com",
    }, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintln(w, `{"data": "Payment confirmed."}`)
    })))
    http.ListenAndServe(":8080", nil)
}

Rust

use axum::{middleware, routing::get, Router};
use l402kit::{l402_middleware, Options};
use std::sync::Arc;

#[tokio::main]
async fn main() {
    let opts = Arc::new(Options::new(100).with_address("you@yourdomain.com"));

    let app = Router::new()
        .route("/premium", get(|| async { "Payment confirmed." }))
        .route_layer(middleware::from_fn_with_state(opts, l402_middleware));

    let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await.unwrap();
    axum::serve(listener, app).await.unwrap();
}

Test it live

# Step 1 โ€” triggers 402 + returns invoice
curl http://localhost:3000/premium
# โ† { "error": "Payment Required", "invoice": "lnbc1u...", "macaroon": "eyJ..." }

# Step 2 โ€” pay the invoice with any Lightning wallet, then:
curl http://localhost:3000/premium \
  -H "Authorization: L402 <macaroon>:<preimage>"
# โ† { "data": "Payment confirmed." }

โ–ถ Try the interactive demo


Why not Stripe?

Stripel402-kit
Minimum fee$0.30< 1 sat (~$0.001)
Settlement time2โ€“7 days< 1 second
ChargebacksYesImpossible โ€” cryptographic proof
Requires accountYesNo โ€” any Lightning wallet
AI agent supportNoYes โ€” 4 SDKs, native
Countries blocked~500 โ€” global by default
ReversibleYesNo โ€” final on receipt
Open sourceNoYes โ€” MIT

Providers

import { BlinkProvider, OpenNodeProvider, LNbitsProvider } from "l402-kit";

// Blink (recommended โ€” free, instant setup)
const provider = new BlinkProvider(process.env.BLINK_API_KEY!, process.env.BLINK_WALLET_ID!);

// OpenNode (production, custodial)
const provider = new OpenNodeProvider(process.env.OPENNODE_KEY!);

// LNbits (self-hosted)
const provider = new LNbitsProvider(process.env.LNBITS_KEY!, "https://your.lnbits.host");

Bring your own node โ€” implement the LightningProvider interface in 5 lines:

import type { LightningProvider } from "l402-kit";

class MyNode implements LightningProvider {
  async createInvoice(amountSats: number) { /* return Invoice */ }
  async checkPayment(paymentHash: string) { /* return boolean */ }
}

Security model

Invoice creation:  paymentHash = SHA256(preimage)
Client payment:    Lightning Network releases preimage to payer
API verification:  SHA256(preimage) == paymentHash  โœ“
Replay protection: each preimage is marked used โ€” works exactly once
Token expiry:      macaroons expire after 1 hour
  • Unforgeable โ€” SHA256 is a one-way function; you cannot fake a preimage
  • No chargebacks โ€” cryptographic settlement, not reversible card auth
  • Replay-safe โ€” MemoryReplayAdapter (dev) or RedisReplayAdapter (production, multi-instance)
  • 600+ automated tests across 5 runtimes (TS, Python, Go, Rust, Cloudflare Workers) โ€” production-grade reliability for autonomous agent workflows
  • Fully auditable โ€” MIT, every line open source

VS Code Extension

Monitor every sat in real-time without leaving your editor.

VS Code Marketplace

  • โšก Live payment feed per endpoint
  • ๐Ÿ“Š Bar chart โ€” 1D / 7D (free) ยท 30D / 1Y / ALL (Pro)
  • ๐ŸŒ 11 languages built-in
  • ๐ŸŽจ Light / dark / auto theme
  • ๐Ÿ”ง Zero config โ€” just set your Lightning Address

Get a Lightning Address (free)

Sign up at dashboard.blink.sv โ€” free, no credit card, instant. Your address: yourname@yourdomain.com

Other wallets: Wallet of Satoshi ยท Phoenix ยท Zeus ยท Alby


Links

ResourceURL
๐Ÿ“– Docs (11 languages)l402kit.com/docs
๐Ÿ“ฆ npmnpmjs.com/package/l402-kit
๐Ÿ PyPIpypi.org/project/l402kit
๐Ÿฆซ Gopkg.go.dev/github.com/shinydapps/l402-kit/go
๐Ÿฆ€ Rustcrates.io/crates/l402kit
๐Ÿ”Œ VS Codemarketplace.visualstudio.com
โšก Lightningshinydapps@blink.sv
๐Ÿ™ GitHubgithub.com/ShinyDapps/l402-kit

MIT โ€” use freely, build freely.

Bitcoin has no borders.


Built with โšก by ShinyDapps


Docs ยท Demo ยท VS Code ยท npm

Related MCP Servers

@agentfund/mcp

๐Ÿ“‡ โ˜๏ธ - Fundraising infrastructure for AI agents on Solana โ€” campaigns, x402 donations, and on-chain reputation. MCP tools for registering agents, creating campaigns, and donating via the x402 pay-to-call flow, backed by Anchor programs (agentregistry, escrow, reputation). npx -y @agentfund/mcp

๐Ÿ’ฐ Finance & Fintech1 views
@asterpay/mcp-server

๐Ÿ“‡ โ˜๏ธ - EUR settlement for AI agents via x402 protocol. Market data, AI tools, crypto analytics โ€” pay-per-call in USDC on Base. SEPA Instant EUR off-ramp.

๐Ÿ’ฐ Finance & Fintech1 views
@czagents/cnb

๐Ÿ“‡ โ˜๏ธ ๐Ÿ  ๐ŸŽ ๐ŸชŸ ๐Ÿง - Czech National Bank (ฤŒNB) daily FX rates: fetch official CZK exchange rates, convert between currencies, fetch historical rates. Cached 10 min to ease upstream load. npm @czagents/cnb or HTTP at cnb.cz-agents.dev/mcp.

๐Ÿ’ฐ Finance & Fintech1 views
@arbitova/mcp-server

๐Ÿ“‡ โ˜๏ธ - Non-custodial on-chain escrow + AI dispute arbitration for agent-to-agent USDC payments on Base. Seven tools covering the full EscrowV1 contract surface: create escrow, mark delivered with on-chain content hash, confirm or dispute, arbiter resolves with signed verdict, cancel/escalate on timeout. npx @arbitova/mcp-server

๐Ÿ’ฐ Finance & Fintech0 views

Engagement

Views
0
Installs
0
Upvotes
0

Views and upvotes are unique per visitor network (hashed IP). Installs count copy actions.

Status

Health: Not checked yet

We have not completed a health check for this listing yet.

No check timestamp yet.

Unclaimed listing (imported or pending owner verification). Claim it โ†’
โ˜… Spotlight Slot

Feature Your MCP Server

Get maximum visibility for your server across our directory, search results, and detail pages.

Spotlight Your Server

Own this project?

This directory is pre-filled from public sources. Claim via GitHub README, site badge, or DNS TXT to get the verified badge and attach your website.

Claim this listing

Promote this listing

Optional paid placement. Free listings stay free forever.

Share & Embed

Add our SVG badge (dark/light directory styles) or embeddable widget to your site.