Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.chipipay.com/llms.txt

Use this file to discover all available pages before exploring further.

What is x402?

x402 is an open HTTP payment protocol backed by Coinbase, Cloudflare, Google, Visa, Stellar, and Lightning Labs. It enables pay-per-request APIs where clients pay with crypto before accessing a resource. The protocol uses HTTP status code 402 Payment Required — a status code reserved since 1997 for exactly this purpose.

How it Works

Client                          Server                          Chipi Paymaster
  |                               |                                |
  |  GET /api/resource            |                                |
  |------------------------------>|                                |
  |  402 + PAYMENT-REQUIRED hdr   |                                |
  |<------------------------------|                                |
  |                               |                                |
  |  [sign SNIP-12 payment]       |                                |
  |                               |                                |
  |  GET /api/resource            |                                |
  |  + X-PAYMENT header           |                                |
  |------------------------------>|                                |
  |                               |  verify + settle (gasless)     |
  |                               |------------------------------->|
  |                               |  { txHash }                    |
  |                               |<-------------------------------|
  |  200 + resource               |                                |
  |<------------------------------|                                |
  1. Client requests a protected resource
  2. Server returns 402 with a PAYMENT-REQUIRED header containing the price
  3. Client signs a USDC payment using SNIP-12 typed data
  4. Client retries the request with the signed payment in the X-PAYMENT header
  5. Server verifies the signature and settles via Chipi’s gasless paymaster
  6. Server returns the resource

Why x402 + Chipi?

Chipi’s existing infrastructure maps perfectly to x402:
x402 ConceptChipi Infrastructure
Payment signingaccount.signMessage() (SNIP-12)
Gasless settlementPaymasterAdapter / sponsored transactions
Automated paymentsSession keys (SNIP-9)
Client walletsCHIPI / READY wallets
Key advantages:
  • Gasless: Payments are settled through Chipi’s paymaster — users never need STRK for gas
  • Session keys: Combined with SNIP-9 sessions, payments happen automatically without user interaction per request
  • Native USDC: All payments use native USDC on Starknet mainnet

SDK Support

PackageWhat’s Available
@chipi-stack/typesTypeScript type definitions
@chipi-stack/coreX402Client — automatic 402 payment handling
@chipi-stack/backendX402Facilitator + x402Middleware for Express
chipi-reactuseX402Payment hook
chipi_sdk (Python)X402Client + X402Facilitator + middleware

Quick Examples

Client: Pay for APIs

import { X402Client } from "@chipi-stack/core";

const client = new X402Client(account, {
  maxPaymentAmount: "1.00", // Max $1 USDC per request
});

// Automatically handles 402 responses
const response = await client.fetch("https://api.example.com/premium-data");
const data = await response.json();

Server: Monetize APIs

import { x402Middleware } from "@chipi-stack/backend";

const facilitator = sdk.createX402Facilitator();

app.get("/premium", x402Middleware({
  facilitator,
  paymentConfig: { amount: "0.01", payTo: "0xYOUR_ADDRESS" },
}), (req, res) => {
  res.json({ data: "premium content", txHash: req.x402.txHash });
});

Next Steps

Client Guide

Pay for APIs from your app

Server Guide

Monetize your API endpoints

Session Keys

Automated payments with sessions