create-typescript-x402-server

Create x402 payment-protected TypeScript servers using Express.js or Hono middleware on Algorand.

Updated Apr 6, 2026
One-click install
npx skills add https://github.com/Rudhrakoushik10/RootNode --skill create-typescript-x402-server-rudhrakoushik10
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: create-typescript-x402-server
Source: https://github.com/Rudhrakoushik10/RootNode/tree/main/projects/.opencode/skill/create-typescript-x402-server
Command: npx skills add https://github.com/Rudhrakoushik10/RootNode --skill create-typescript-x402-server-rudhrakoushik10

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @x402-avm/express, @x402-avm/hono, @x402-avm/core, @x402-avm/avm, @x402-avm/paywall, express, hono, algosdk, and includes references (resource) components.

What problem does it solve? Building APIs that charge per request requires implementing the x402 payment protocol: returning 402 Payment Required responses, verifying X-PAYMENT headers, and settling Algorand transactions through a facilitator. This Skill provides the complete workflow for gating Express.js or Hono routes behind AVM payments without writing the protocol logic from scratch. ## Core Features & Use Cases - Payment Middleware Setup: Configure three middleware variants (paymentMiddlewareFromConfig, paymentMiddleware, paymentMiddlewareFromHTTPServer) to protect routes with per-endpoint USD pricing. - Multi-Network and Multi-Asset Support: Accept payments on Algorand testnet or mainnet, in ALGO or USDC ASA, and combine with EVM networks for cross-chain routes. - Facilitator and Paywall Servers: Run your own facilitator with an AVM signer, add browser paywall UI, dynamic pricing functions, and fee abstraction. - Use Case: You want to monetize a weather API. Apply the middleware with a route config mapping "GET /api/weather" to a $0.01 price, and unpaid callers receive a 402 response while paying callers pass through to the handler. ## Quick Start Ask the AI to create an Express server with x402 payment middleware protecting a GET /api/weather route at $0.01 paid to your Algorand testnet address.

Frequently Asked Questions about create-typescript-x402-server

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add x402 payment middleware to an Express server?

Install @x402-avm/express, @x402-avm/avm, and @x402-avm/core, then create an HTTPFacilitatorClient and x402ResourceServer, call registerExactAvmScheme(server), and apply paymentMiddleware(routes, server) before your route handlers. Routes listed in the config return 402 until payment is verified.

How do I protect Hono routes with x402 payments?

Use the @x402-avm/hono package, which exports the same three middleware variants returning Hono MiddlewareHandler. For Node.js add @hono/node-server; for Cloudflare Workers set syncFacilitatorOnStart to false to avoid cold-start delays.

What is the difference between paymentMiddlewareFromConfig and paymentMiddleware?

paymentMiddlewareFromConfig creates the x402ResourceServer internally and is the simplest option for quick starts. paymentMiddleware accepts a pre-configured x402ResourceServer instance, which you need when registering multiple schemes or reusing the server across middleware.

Can x402 routes accept both ALGO and USDC payments on Algorand?

Yes. Set the network to ALGORAND_TESTNET_CAIP2 or ALGORAND_MAINNET_CAIP2 for ALGO payments, and add extra.asset with USDC_TESTNET_ASA_ID or USDC_MAINNET_ASA_ID to accept USDC. You can also pass an array to accepts for multi-network or cross-chain routes.

Why do all my routes return 402 Payment Required?

This usually means route patterns are too broad or the AVM scheme was not registered. Check that your route patterns match only intended paths and that registerExactAvmScheme(server) is called unconditionally before applying the middleware.

Do I need to run my own x402 facilitator server?

No. You can point HTTPFacilitatorClient at a public facilitator such as https://facilitator.goplausible.xyz. Run your own facilitator only if you need custom signing, fee abstraction, or control over the verify and settle endpoints.