create-python-x402-server

Create FastAPI or Flask servers that protect API endpoints with Algorand USDC payments via x402 middleware.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires x402-avm, and includes references (resource) components.

What problem does it solve? Monetizing API endpoints requires building payment verification, settlement, and request interception logic from scratch. This Skill guides you through adding x402 payment middleware to FastAPI or Flask servers so clients pay in USDC on Algorand before accessing protected routes. ## Core Features & Use Cases - Framework-Specific Middleware Setup: Configure async middleware for FastAPI (PaymentMiddlewareASGI) or sync middleware for Flask (PaymentMiddleware) with matching facilitator clients and resource servers. - Flexible Route Pricing: Define per-route payment requirements using simple string prices like "$0.01" or explicit AssetAmount values with USDC ASA IDs, including wildcard path patterns. - Multi-Network Support: Accept payments across Algorand, EVM, and Solana networks by registering multiple schemes on a single resource server. - Use Case: You have a weather data API built with FastAPI. Use this Skill to protect the /api/weather route so clients must pay $0.01 in USDC on Algorand Testnet before receiving data, while leaving your /health endpoint free. ## Quick Start Ask the AI to create a FastAPI server with x402 payment middleware that charges $0.01 in Algorand USDC for access to a weather endpoint.

Frequently Asked Questions about create-python-x402-server

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

FAQPage Schema
How do I add x402 payment middleware to a FastAPI server?

Install x402-avm with the fastapi extra, create an HTTPFacilitatorClient and x402ResourceServer, register the Algorand scheme, then add PaymentMiddlewareASGI via app.add_middleware with your route configuration mapping paths to PaymentOption prices.

How do I protect Flask API endpoints with Algorand USDC payments?

Use the sync variants: x402ResourceServerSync and HTTPFacilitatorClientSync, then wrap your Flask app with PaymentMiddleware(app, routes, server). Routes listed in the config require payment while unlisted routes pass through freely.

What is the difference between FastAPI and Flask x402 middleware setup?

FastAPI uses async components (x402ResourceServer, HTTPFacilitatorClient, PaymentMiddlewareASGI) while Flask uses sync variants (x402ResourceServerSync, HTTPFacilitatorClientSync, PaymentMiddleware). Mixing async components with Flask causes TypeError exceptions.

Can one x402 server accept payments on multiple blockchain networks?

Yes, register multiple schemes on the resource server (ExactAvmServerScheme, ExactEvmServerScheme, ExactSvmServerScheme) and provide a list of PaymentOption entries per route, each with its own network identifier and pay_to address.

Why does my x402 middleware return 402 for all requests?

This typically means the facilitator is unreachable, so payment verification cannot complete. Check your FACILITATOR_URL configuration and network connectivity to the facilitator service.

How do I set exact USDC amounts instead of dollar string prices?

Use AssetAmount with the amount in atomic units and the ASA ID as the asset, for example amount="10000" with asset="10458941" for 0.01 USDC on Algorand Testnet, including optional decimals metadata.