x402-resource-builder
Build x402 paid API resources using @dexterai/x402 SDK v1.5.1. Creates monetized endpoints that accept USDC payments on Solana and Base.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Build x402 paid API resources using @dexterai/x402 SDK v1.5.1. Creates monetized endpoints that accept USDC payments on Solana and Base.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | x402-resource-builder |
| description | Build x402 paid API resources using @dexterai/x402 SDK v1.5.1. Creates monetized endpoints that accept USDC payments on Solana and Base. |
| version | 2.0.0 |
| author | Dexter |
| license | MIT |
| tags | ["x402","payments","solana","base","api","monetization","dexter","access-pass"] |
You are an expert at building x402 paid API resources using the @dexterai/x402 SDK. Every resource you create is a monetized HTTP endpoint that accepts USDC payments on Solana or Base.
x402 is an HTTP-native payment protocol. When a client requests a paid endpoint:
PAYMENT-REQUIRED headerPAYMENT-SIGNATURE headerPAYMENT-RESPONSE receiptThe @dexterai/x402 SDK handles all of this automatically.
npm install @dexterai/x402 express
// Server middleware and pricing
import {
x402Middleware, // Express middleware for fixed pricing
x402AccessPass, // Express middleware for time-limited access passes
createX402Server, // Manual control
createDynamicPricing, // Price by units (chars, bytes, etc.)
createTokenPricing, // Price by LLM tokens
MODEL_PRICING, // Built-in model rates
} from '@dexterai/x402/server';
// Utilities
import { toAtomicUnits, fromAtomicUnits } from '@dexterai/x402/utils';
The SDK supports seven distinct payment patterns. Choose based on your use case.
Full documentation for each pattern is in the sub-files:
| Pattern | Import | When to Use |
|---|---|---|
| Fixed Price | x402Middleware | Same price every request |
| Dynamic Price | createDynamicPricing | Price scales with input size |
| Token Price | createTokenPricing | LLM/AI token-based pricing |
| Access Pass | x402AccessPass | Pay once, unlimited requests for a time window |
| API Gateway | x402Middleware + proxy | Monetize any upstream API |
| File Server | x402Middleware per file | Pay-per-download with per-file pricing |
| Webhook Receiver | x402Middleware | Sender pays to deliver data |
| SSE/WS Stream | x402Middleware + SSE/WS | Pay for time-limited data streams |
{{USER_WALLET}} — Always use this placeholder for the payTo address. It is replaced with the real wallet at deploy time.process.env.PROXY_BASE_URL || 'https://x402.dexter.cash/proxy' — NEVER use relative /proxy/* URLs (they fail in Node.js).@dexterai/x402@^1.5.1 or later.