Skip to content
Reinkey

Reinkey Meter

Charge for exactly what was used.

Add meter() to an endpoint. Unpaid requests get the terms in a 402, paid requests are verified in milliseconds, and thousands of payments land in your wallet in a single on-chain transaction.

  • Request, token or second: you pick the unit
  • Vouchers verify off-chain: median under 1 ms
  • Thousands of payments settle in one transaction

Your first paid endpoint in 60 seconds

Install the package, pass the facilitator URL and your Stellar address, set a price. The 402 response, voucher verification and settlement come built in.

bash
npm i @reinkey/meter

Unpaid requests get the terms

Agents don't read docs. The 402 body states the price, unit, network and pay-to address in a machine-readable shape; @reinkey/sdk handles the rest.

server.ts
import express from "express";
import { reinkey } from "@reinkey/meter";

const rk = await reinkey({
  facilitator: "https://reinkey.onrender.com",
  payTo: "G…YOUR_STELLAR_ADDRESS",
});

const app = express();

// 0.0005 USDC per call. No plans, no invoices, no API keys.
app.get(
  "/book",
  rk.meter({ price: 5000n, unit: "request", description: "Order book" }),
  (req, res) => res.json(orderBook()),
);
GET /book
HTTP/1.1 402 Payment Required
PAYMENT-REQUIRED: eyJ4NDAyVmVyc2lvbiI6Mi…

{
  "x402Version": 2,
  "error": "PAYMENT_REQUIRED",
  "accepts": [{
    "scheme": "channel",
    "network": "stellar:testnet",
    "amount": "5000",
    "unit": "request",
    "payTo": "G…YOUR_STELLAR_ADDRESS"
  }]
}
  • 01Three units

    request: per call. token: slice by slice on a streamed response. second: for exactly as long as a live feed is listened to. Payment stops when the connection drops; the stream stops when the deposit runs out. All three in one package; rk.stream() for streams.

  • 02Non-custodial

    Funds sit either in the buyer's account or in the channel contract. The facilitator can't touch them: anyone can verify a voucher, anyone can trigger settlement, and the money only goes to you.

  • 03Automatic settlement

    Once accumulated vouchers pass a threshold, or the channel nears expiry, the facilitator settles with a single claim transaction. Don't want to wait? Trigger it yourself: anyone can call claim.

  • 04Standard x402

    PAYMENT-REQUIRED, PAYMENT-SIGNATURE and PAYMENT-RESPONSE are the same headers as x402 v2. The channel scheme is offered next to exact as a second option.

  • 05No network fees

    Buyers don't need to hold XLM; the facilitator pays transaction fees. You only ever receive USDC.

  • 06Explainable rejections

    Every rejected payment returns a reason code: CHANNEL_EXHAUSTED, VOUCHER_UNDERPAID, WRONG_PAYEE, CHANNEL_EXPIRING. The agent reads what to fix from the body; nobody opens a support ticket.

What exists today, and what doesn't

  • Runs on Stellar testnet; the contracts haven't been audited yet.
  • The package targets Express and compatible servers (Nest, Connect).
  • Per-request, per-token and per-second billing are all in the package: stream sessions live on the facilitator and are open to external sellers over HTTP. Verified on testnet from a separate server.

Open your first paid endpoint today.