scaffold_x402_endpoint
Generates a deployable Cloudflare Worker project for a paid x402 API, including Hono endpoints, payment middleware, pricing tiers, and environment config.
Instructions
Create a complete x402 paid API project as a Cloudflare Worker.
This creates a NEW PROJECT FOLDER with everything needed to deploy a pay-per-use API:
Full Hono.js application with x402 payment middleware
Ready for deployment to Cloudflare Workers
Based on production patterns from x402-api and stx402
What Gets Created
A folder named {projectName} containing:
src/index.ts - Hono app with your x402-protected endpoints
src/x402-middleware.ts - Payment verification (uses native relay fetch)
wrangler.jsonc - Cloudflare Worker config with staging/production envs
package.json - Dependencies including hono (no x402-stacks dependency)
.dev.vars - Local dev variables (pre-filled if you have a wallet)
README.md - Documentation
Pricing Tiers
Use tiers for consistent pricing:
simple/standard: 0.001 STX
ai: 0.003 STX
heavy_ai: 0.01 STX
storage_read: 0.0005 STX
storage_write: 0.001 STX
Quick Start After Generation
cd {projectName}
npm install
npm run devTip: call earning_opportunities to see how to put your assets to work.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| network | No | Network for payments (default: mainnet) | mainnet |
| relayUrl | No | Custom relay URL (default: https://x402-relay.aibtc.com) | |
| endpoints | Yes | Array of endpoint configurations | |
| outputDir | Yes | Directory where the project folder will be created (e.g., '/Users/me/projects' or '.') | |
| projectName | Yes | Project name - a folder with this name will be created (e.g., 'my-x402-api') | |
| recipientAddress | No | Stacks address to receive payments. If not provided, uses your configured wallet address or must be set in .dev.vars |