Tollstile

Installation

Packages, what each one does, and which are available today.

Public Beta · early access
npm install tollstile
PackagePurposeStatus
tollstileCore: quotes, execution plans, idempotency, structured denials, authorizations, charges, flows, reconciliation, access policies (subscriber, credits, payPerCall), requirements (limit, payers, when), test rail, memory ledgerImplemented
@tollstile/honoHono middleware (Node, Bun, Deno, Workers)Implemented
@tollstile/mcpMCP tools on @modelcontextprotocol/sdkImplemented; tested with the real SDK
@tollstile/expressExpress 5 routesImplemented; tested with a real Express app
@tollstile/nextNext.js App Router route handlersImplemented; not yet run inside a Next.js app
@tollstile/fetchWeb-standard handlers: Workers, Deno, BunImplemented; running on Cloudflare Workers in the live demo. Not yet run on Deno or Bun
create-tollstileProject template with a paid route and a paying test agentImplemented
@tollstile/x402x402 rail (exact, upto) over HTTP and MCPexact verified on Base Sepolia with x402.org, including a real USDC transfer; upto and production facilitators not verified
@tollstile/mppMPP rails: Stripe charge, Tempo charge, Tempo sessionStripe charge verified in Stripe test mode, including retries, refunds, and reconciliation. Tempo not run against a node; Tempo session is experimental
@tollstile/l402L402 (Lightning) railImplemented; not verified against a Lightning node
@tollstile/kyapayKYAPay railImplemented; not verified against Skyfire
@tollstile/web-bot-authverifiedAgent() via HTTP message signaturesImplemented; not verified against a live agent
@tollstile/ap2userMandate() via AP2 mandatesExperimental
@tollstile/postgresPostgres ledger: pg, postgres.js, Neon, PGliteImplemented; tested on PGlite, and on a real PostgreSQL 16 server in CI under 100-way concurrency and crash recovery
@tollstile/sqliteSQLite ledger: node:sqlite, better-sqlite3, bun:sqlite, D1Implemented; tested on node:sqlite, and running on D1 in the live demo

Every package is tested against fakes, published test vectors, and reference libraries. Two have been run against real providers in test environments: x402 on Base Sepolia, and MPP's Stripe rail in Stripe test mode. The rest — Tempo, Lightning nodes, Skyfire — have never been contacted. Each rail's page has a Verification status section with what was tested and how to check it live.

Create an instance

import { createTollstile, memoryLedger, testRail } from "tollstile";

export const toll = createTollstile({
  rails: [testRail()],
  ledger: memoryLedger(),
  // Required with live rails: signs quotes. Use at least 32 random characters.
  // secret: process.env.TOLLSTILE_SECRET,
});
OptionDefaultPurpose
rails—Rails you accept. Test rails cannot be mixed with live rails.
ledger—Where authorizations, charges, and claims are recorded.
secretrandom (test rails only)Signs quotes. A list rotates: the first signs, all verify.
quoteTtlMs5 minutesHow long a quote is honored.
maxRequestBytes1 MiBThe largest body this instance will price. A request declaring more is refused before anything else happens; one that declares nothing is refused the moment its stream passes the limit, on any route that reads the body. Routes that never read it are not buffered. See SECURITY.md.
providerTimeoutMs10 secondsUpper bound for any provider call.
clocksystem clockInject for tests.
onEvent—Typed lifecycle events for logs and metrics.

The conformance kit is exported from tollstile/testing, a subpath of tollstile; there is no separate testing package to install.

On this page