Back to home
Download
Install Tollgate SDKs
Both SDKs are MIT-licensed and published to npm. Install only what your side of the market needs.
tollgate-sdk
Publisher SDK
Drop-in middleware for Express, Next.js, Fastify, and Cloudflare Workers. Requires only your Solana wallet address — no API key, no signup.
Install
npm install tollgate-sdkExpress
import { createPaywall } from "tollgate-sdk"; import { expressMiddleware } from "tollgate-sdk/express";Next.js
import { paywallMiddleware } from "tollgate-sdk/nextjs";Fastify
import { fastifyPlugin } from "tollgate-sdk/fastify";Cloudflare Workers
import { cloudflareHandler } from "tollgate-sdk/cloudflare";Minimum config
const paywall = createPaywall({
walletAddress: process.env.SOLANA_WALLET_ADDRESS,
network: "mainnet-beta",
basePriceMicroUsdc: 1_000, // $0.001 per crawl
});
app.use(expressMiddleware(paywall));tollgate-agent-sdk
Agent SDK
Drop-in 402-paywall client for AI agents. Handles detection, payment, and retry automatically. Peer dependencies required.
Install (with peer deps)
npm install tollgate-agent-sdk @solana/web3.js @solana/spl-token @x402-solana/coreLangChain tool
import { paywallFetchTool } from "tollgate-agent-sdk/langchain";Minimum config
import { createAgentPaywallClient, fromKeypairFile } from "tollgate-agent-sdk";
const client = createAgentPaywallClient({
network: "mainnet-beta",
signer: fromKeypairFile(), // ~/.config/solana/id.json
maxAmountMicroUsdc: 10_000, // never pay > $0.01/request
maxTotalMicroUsdc: 1_000_000, // session budget: $1.00
});
const res = await client.fetch("https://site.com/article");
console.log("paid:", res.paywallPayment?.signature);