Pay-per-request
without the payments.

An SDK that intercepts HTTP 402 responses and resolves them automatically on testnet. Your code calls fetch — we handle wallets, faucets, and on-chain payment.

fetch()402payretry200 OK
Open Playground$ npm install solgateskit-sdk
Quick Start

Two sides. Both simple.

Client auto-handles payment flow. Server adds one middleware line.

client.ts
import { sgFetch } from "solgateskit-sdk";

// That's it. No wallet setup, no config.
const res = await sgFetch(
  "https://api.example.com/data"
);
const data = await res.json();

// Under the hood:
// 1. SDK generated a Solana keypair
// 2. Airdropped SOL from devnet faucet
// 3. Server returned 402 Payment Required
// 4. SDK sent 0.001 SOL on Solana
// 5. Retried with payment proof → 200 OK
server.ts
import { sgGate } from "solgateskit-sdk/server";

// One line. That's the entire server setup.
app.use("/api/data", sgGate({
  amount: 0.001,        // SOL per request
  recipient: "YOUR_WALLET",
  network: "devnet",
}));

app.get("/api/data", (req, res) => {
  // Only reached after payment verified
  res.json({ data: "premium content" });
});
Protocol

The 402 flow, visualized.

HTTP 402 Payment Required exists since 1999. Solgateskit makes it real — on Solana.

01REQUEST

Your code calls fetch

Call sgFetch() with any URL. SDK auto-generates a Solana keypair and airdrops SOL from the devnet/testnet faucet.

02402

Server returns 402

The API responds with HTTP 402 Payment Required and a header specifying the cost in SOL and the recipient address.

03SOL

SDK pays on Solana

The SDK builds a SOL transfer transaction, signs it with the ephemeral keypair, and confirms it on Solana. 1–3 seconds.

04200 OK

Data returned

SDK retries the original request with a payment receipt header. Server verifies on-chain and returns data.

Capabilities

Built for machines talking to machines.

Every design decision optimizes for developer experience and API-first workflows.

2 lines

Zero Config

Import the SDK. Call fetch. Wallet creation, faucet funding, and payment handling are all automatic. No env vars, no accounts, no onboarding flow.

RFC 7231

HTTP 402 Protocol

Built on the HTTP standard for payment-required responses. Server returns 402 with payment terms, client pays, retries with proof. RESTful, stateless, inspectable.

3 networks

3 Networks

Test on devnet (free airdrop), testnet (free airdrop), or point at mainnet with a real wallet. Same SDK, same interface — one config flag to switch.

1 flag

Production Path

Same SDK interface, same server middleware. When you're ready for production, swap one config flag. No rewrite, no new integration, no new mental model.

1 line

Express Middleware

Server-side is a single middleware function — sgGate({ amount }). Drop it before any route handler. Works with existing auth, rate limiting, and error handling.

6 events

Event Hooks

onStep callback gives you real-time visibility into the payment lifecycle. Wallet creation, faucet funding, payment submission, confirmation — all observable.

Stop mocking payments.
Start testing them.

The playground lets you fire real requests against a live testnet server. See every step of the 402 flow as it happens.

402

HTTP Standard

3

Solana Networks

$0

Real Cost