Skip to content

x402-deploy Overview

x402-deploy is a deployment toolkit for creating paid APIs that accept cryptocurrency payments.

What is x402-deploy?

x402-deploy enables you to:

  • Create paid APIs with simple configuration
  • Accept crypto payments automatically (USDC, USDs)
  • Deploy anywhere (Vercel, AWS, Docker, etc.)
  • Register in the AI agent discovery network

Key Features

πŸš€ One-Command Deploy

npx @nirholas/x402-deploy

πŸ’° Flexible Pricing

{
  "pricing": {
    "routes": {
      "GET /api/free/*": "free",
      "GET /api/basic/*": "$0.001",
      "GET /api/premium/*": "$0.01"
    }
  }
}

πŸ” AI Agent Discovery

Your API is automatically discoverable by AI agents:

// AI agents can find your API
const apis = await discover({
  category: "weather",
  maxPrice: "$0.01"
});

πŸ“Š Built-in Dashboard

Monitor revenue, usage, and analytics in real-time.

Quick Start

1. Create Config File

Create x402.config.json:

{
  "name": "my-paid-api",
  "payment": {
    "wallet": "0xYourWalletAddress",
    "network": "eip155:42161"
  },
  "pricing": {
    "routes": {
      "GET /api/*": "$0.001"
    }
  }
}

2. Wrap Your API

import express from "express";
import { wrapWithX402 } from "@nirholas/x402-deploy/gateway";

const app = express();

app.get("/api/data", (req, res) => {
  res.json({ data: "premium content" });
});

// Add x402 payment layer
const wrappedApp = wrapWithX402(app);

wrappedApp.listen(3000);

3. Deploy

npx @nirholas/x402-deploy deploy

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     x402-deploy Stack                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚
β”‚  β”‚   Your API       β”‚    β”‚   x402 Gateway   β”‚               β”‚
β”‚  β”‚   (Express,      │◄───│   - Payment      β”‚               β”‚
β”‚  β”‚    Fastify,      β”‚    β”‚     Verification β”‚               β”‚
β”‚  β”‚    Next.js)      β”‚    β”‚   - Rate Limitingβ”‚               β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚   - Logging      β”‚               β”‚
β”‚                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
β”‚                                   β”‚                         β”‚
β”‚                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚
β”‚                          β”‚   Discovery      β”‚               β”‚
β”‚                          β”‚   - Registration β”‚               β”‚
β”‚                          β”‚   - Searchable   β”‚               β”‚
β”‚                          β”‚   - Categories   β”‚               β”‚
β”‚                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
β”‚                                   β”‚                         β”‚
β”‚                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚
β”‚                          β”‚   Dashboard      β”‚               β”‚
β”‚                          β”‚   - Revenue      β”‚               β”‚
β”‚                          β”‚   - Analytics    β”‚               β”‚
β”‚                          β”‚   - Settings     β”‚               β”‚
β”‚                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
β”‚                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Use Cases

{
  "pricing": {
    "routes": {
      "GET /api/price/:symbol": "$0.0001",
      "GET /api/forecast/:symbol": "$0.01"
    }
  }
}

Compute APIs

{
  "pricing": {
    "routes": {
      "POST /api/analyze": "$0.05",
      "POST /api/generate": "$0.10"
    }
  }
}

Premium Content

{
  "pricing": {
    "routes": {
      "GET /api/articles/:id": "$0.001",
      "GET /api/reports/:id": "$0.50"
    }
  }
}

Supported Frameworks

Framework Package
Express @nirholas/x402-deploy/express
Fastify @nirholas/x402-deploy/fastify
Next.js @nirholas/x402-deploy/next
Hono @nirholas/x402-deploy/hono
Gin (Go) x402/gin-gonic
Python x402/python
Java x402/java

Deployment Targets

  • Vercel - Serverless functions
  • AWS Lambda - Serverless
  • Docker - Containers
  • Railway - One-click deploy
  • Fly.io - Edge deployment
  • Self-hosted - Any Node.js server

Documentation