Getting StartedQuick Start

Quick Start

Get up and running with T402 in under 5 minutes.

What You’ll Build: A payment-protected API endpoint and a client that pays for it automatically — in under 5 minutes.

⚠️

Testing first? Use the Sandbox to test verify/settle flows with magic test addresses — no API key, no real funds, no wallet needed. Try the interactive playground.

Get an API Key

Register for a free API key to use the production facilitator:

  1. Go to facilitator.t402.io/register
  2. Enter your email and project name
  3. Copy your t402_sk_... API key

Free tier: 1,000 transactions/month, all 11 chain families, 0% fee. See pricing tiers for details.

Your key unlocks the dashboard with usage charts, key rotation, webhook settings, and IP restrictions.

Overview

T402 enables HTTP-native payments using USDT and USDT0. Here’s what a typical flow looks like:

Client requests a protected resource

Server responds with 402 Payment Required

Client signs a payment authorization

Server verifies and settles the payment

Client receives the requested resource

Server Setup

import express from 'express'
import { paymentMiddleware } from '@t402/express'
import { ExactEvmScheme } from '@t402/evm'
 
const app = express()
 
// Add payment middleware
app.use(paymentMiddleware({
  'GET /api/premium': {
    price: '$0.01',
    network: 'eip155:8453', // Base
    payTo: '0xYourAddress...',
    description: 'Premium API access'
  }
}))
 
app.get('/api/premium', (req, res) => {
  res.json({ data: 'Premium content!' })
})
 
app.listen(3000)

Client Setup

import { t402Client, wrapFetchWithPayment } from '@t402/fetch'
import { registerExactEvmScheme } from '@t402/evm/exact/client'
import { privateKeyToAccount } from 'viem/accounts'
 
// Create and configure client
const client = new t402Client()
registerExactEvmScheme(client, {
  signer: privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
})
 
// Wrap fetch to automatically handle payments
const fetchWithPayment = wrapFetchWithPayment(fetch, client)
 
// Make requests - payments are handled automatically!
const response = await fetchWithPayment('https://api.example.com/api/premium')
const data = await response.json()

Installation

# Core + EVM (most common)
pnpm add @t402/core @t402/evm
 
# With Express middleware
pnpm add @t402/core @t402/evm @t402/express
 
# Full client setup with fetch wrapper
pnpm add @t402/core @t402/evm @t402/fetch
 
# All mechanism packages (multi-chain)
pnpm add @t402/core @t402/evm @t402/svm @t402/ton @t402/tron @t402/near @t402/aptos @t402/tezos @t402/polkadot @t402/stacks @t402/cosmos @t402/stellar

Requirements

LanguageVersion
TypeScriptNode.js 18+ or Bun 1.0+, TypeScript 5.0+
PythonPython 3.10+
GoGo 1.24+
JavaJava 17+, Maven or Gradle

MCP Server (AI Agents)

npm install -g @t402/mcp   # Install globally
npx @t402/mcp              # Or run directly

See MCP Integration for configuration details.

What’s Next?