402

Gas-Free Payments
for the Programmable Web

The missing piece of the internet is here. PAY402 is the Express middleware that turns HTTP 402 into a native, gas-free payment layer for your APIs.

Why PAY402?

Built for developers, powered by 100Pay.

⛽

Gas-Free Payments

Accept payments across 8+ blockchains without users needing ETH or SOL for gas. Frictionless crypto payments are finally here.

🔌

Express Middleware

Drop-in integration for your Node.js apps. Just `app.use(withPay402)` and your routes are instantly monetized.

🤖

NanoApps Discovery

Automatically uploads your route configurations to the NanoApps Store, making them discoverable by AI agents like Claude and Gemini.

⚡

Smart Caching

Optimized for performance. Route configurations are only uploaded when changes are detected, keeping your startup times fast.

🏦

Auto-Settlement

Payments are automatically settled in stablecoins or fiat directly to your bank account via the 100Pay infrastructure.

🛡️

TypeScript Native

Built with TypeScript from the ground up. Enjoy full type safety, autocompletion, and a developer experience that just works.

Integration is Simple

Choose your integration path

import express from 'express';
import { withPay402 } from '@100pay-hq/pay402';

const app = express();

// Configure your monetized routes
const config = {
    _100PayApiKey: "your-api-key",
    wallet: "0xYourWallet...",
    routes: [
        {
            path: "/api/premium-data",
            method: "GET",
            price: async (req) => ({
                amount: "1.00",
                currency: "USD"
            })
        }
    ]
};

// Apply the middleware
app.use(withPay402(config));

app.listen(3000);
import axios from 'axios';
import { withPay402Interceptor } from '@100pay-hq/pay402-axios';
import { createWalletClient, http } from 'viem';

const client = axios.create({ baseURL: 'https://api.example.com' });

// 1. Setup Wallet for signing
const walletClient = createWalletClient({
    account: privateKeyToAccount("0xYourPrivateKey"),
    transport: http()
});

// 2. Define payment handler
const signTransaction = async (pricing, resource) => {
    // Select payment option (e.g. USDC, SOL, PAY)
    const option = pricing.find(p => p.currency === 'USDC');
    
    // Execute transfer via 100Pay.js
    const tx = await _100PayClient.transfer.executeTransfer({
        amount: option.amount,
        to: option.payTo,
        symbol: "USDC"
    });
    
    return tx.transactionHash;
};

// 3. Attach Interceptor
withPay402Interceptor(client, signTransaction, walletClient);

// 4. Make requests (payments handled automatically)
await client.post('/premium-service', { data: 'foo' });