STELLARPAY

Turn any API route — or any MCP tool — into a paid endpoint on Stellar.

Agents can't sign up, can't hold a credit card, and can't wait for an invoice. stellarpay is a set of npm packages that let them just pay: one config object gates a route behind x402 or MPP, and one client auto-pays any 402 it meets, within spend limits you set.

What we ship is the SDK — six packages on npm under @stellarpay-sdk. The demos below exist to prove the SDK works against real testnet money; they're not the product.

The SDK — six packages

# one seller and one buyer, both real
npm install @stellarpay-sdk/express   # or /hono, /fastify
npm install @stellarpay-sdk/client
0.1.0
@stellarpay-sdk/core
The paywall engine: config validation, route matching, and the three payment schemes behind one Request → Response handler.
0.1.0
@stellarpay-sdk/express
One-line Express middleware. app.use(stellarpayExpress(cfg)).
0.1.0
@stellarpay-sdk/hono
One-line Hono middleware — the thinnest adapter, no conversion layer.
0.1.0
@stellarpay-sdk/fastify
Fastify plugin, registered at the app root before your routes.
0.1.0
@stellarpay-sdk/client
createPayingFetch() — a fetch that transparently pays any 402, x402 or MPP, with hard spend caps.
0.1.0
@stellarpay-sdk/mcp
Per-tool-call payments for MCP servers, settled in-protocol — plus a paying MCP client.

The whole integration

Sell

import { stellarpay } from "@stellarpay-sdk/core";
import { stellarpayExpress } from "@stellarpay-sdk/express";

const paywall = stellarpay({
  network: "stellar:testnet",
  payTo: "G…",
  routes: {
    "GET /weather": { price: "$0.001" },
  },
});

app.use(stellarpayExpress(paywall)); // before routes

Buy

import { createPayingFetch } from "@stellarpay-sdk/client";

const payFetch = createPayingFetch({
  secret: process.env.AGENT_SECRET,
  network: "stellar:testnet",
  limits: { maxPerCall: "$0.01", maxTotal: "$1.00" },
});

// 402 → pays → retries. Your code never sees it.
await payFetch("https://api.example/weather");

Change scheme on a route to settle over MPP instead of x402 — including server-sponsored gas, so the buyer pays no fees. Nothing else in your app changes.

Seven demos we built to prove it

All seven run live on Stellar testnet right now, selling real Horizon data for real money. Press the button on the dashboard and an autonomous agent goes shopping across them.

express-apix402mpp

The flagship seller: a free route, an x402 route, and an MPP route with sponsored gas — all from one config. Asset reports and account forensics.

visit ↗
hono-apix402

Whale alerts, paywalled in a six-line diff. The proof that adding payments to an existing API is a config change, not a rewrite.

visit ↗
fastify-apimpp

Live fee and congestion stats over MPP — a third framework, to show the adapter layer is genuinely thin.

visit ↗
mcp-servermcp

An MCP server with individually priced tools. The payment is the tool call — no API keys, no subscription, settled in-protocol.

visit ↗
agent

A Claude-driven buyer with a funded wallet and a hard budget. It decides what intel it needs and buys it — the only service here that consumes the SDK rather than exposing it.

drive it ↗
dashboard

Mission control: a live receipt feed, a per-example runner, a chat you can talk to the agent through, and an on-chain verify link on every row.

open ↗
private-apishielded ◆

Getting paid without learning who paid you. Payment arrives from a shielded pool, so the seller can prove it was paid and still can't identify its customer. One shielded transfer opens a credit line; requests then cost 0.4s and nothing on-chain. Pick the shielded ◆ target on the dashboard and watch a full cycle settle.

run it live ↗  ·  read the writeup ↗

What actually happens on the wire

  1. An agent requests a paid route. It gets a 402 with a machine-readable challenge — price, asset, recipient, network.
  2. The client checks the price against its spend limits and refuses if it's over budget. This happens before anything is signed.
  3. It signs and settles on Stellar — via the facilitator for x402, or directly for MPP, with gas optionally sponsored by the seller.
  4. It retries automatically with proof of payment. Your calling code just sees a 200.
  5. The seller's onPayment hook fires with a receipt carrying the real transaction hash — verifiable on any block explorer.

See it settle real money

An autonomous agent, a live feed, and a transaction hash you can check yourself.

▶ TRY IT YOURSELF