[v3.0.0] :: buildx402

// The developer toolkit for payment-gated APIs on Aptos

> Scaffold. Configure. Deploy. Earn.

$ scroll --down

// FEATURES

> What you get

$ monetize

Pay-Per-Request APIs

Gate any API endpoint behind USDC micropayments. No subscriptions, no API keys, no middlemen.

$ buildx402

CLI Toolkit

Scaffold, inspect, and pay x402 endpoints from your terminal. One command to start building.

$ transact

Aptos + USDC

Low-fee, high-speed payments on Aptos blockchain. USDC stablecoin for predictable pricing.

$ init

Instant Scaffolding

npx buildx402 my-app creates a production-ready Next.js app with payment middleware wired up.

$ wallet

Wallet Generation

Generate Aptos Ed25519 wallets from the CLI. No external tools or browser extensions needed.

$ inspect

Endpoint Inspection

Probe any x402 endpoint to see payment requirements, pricing, and network details before paying.

// HOW_IT_WORKS

> Four steps to earning

01
Scaffold

$ npx buildx402 my-app

> Scaffolds a Next.js project with x402 payment middleware pre-configured.

02
Configure

$ npx buildx402 wallet create

> Generates an Aptos Ed25519 wallet. Fund it with testnet USDC via the faucet.

03
Deploy

$ vercel deploy

> Ship to production. Your API endpoints are now payment-gated.

04
Earn

$ npx buildx402 inspect <url>

> Every request pays you USDC. Inspect and monitor endpoints in real time.

// CODE_EXAMPLE

> It's just middleware

Any route you build becomes a paid endpoint. Add it to the config, set your price, and the middleware handles the rest — payment verification, 402 responses, and USDC collection. No payment logic in your API code.

middleware.ts
// middleware.ts — gate any route, set any price
import { paymentProxy } from "@rvk_rishikesh/next";
 
const paymentRoutes = {
 
// A fortune endpoint — 0.01 USDC per request
"api/fortune": {
accepts: [{ scheme: "exact", price: "0.01", ...opts }],
},
 
// A premium data feed — 0.50 USDC per request
"api/data": {
accepts: [{ scheme: "exact", price: "0.50", ...opts }],
},
 
// An AI inference endpoint — 1.00 USDC per call
"api/generate": {
accepts: [{ scheme: "exact", price: "1.00", ...opts }],
},
};
 
// That's it. The middleware intercepts requests,
// returns 402 until paid, then forwards to your API.
export async function middleware(request) {
return await proxy(request);
}

> Your API routes stay clean — just return data.

> The middleware handles 402 negotiation, payment verification, and USDC settlement.

> Add a route. Set a price. Ship it.

// CLI_DEMO

> Your terminal, your toolkit

buildx402 — zsh