Skip to main content
Glama

x402 & MCP Non-Custodial Crypto Paywall Starter (Python FastAPI + Node.js 18+)

PayGate x402 & Checkout Gate GitHub Marketplace Protocol: x402 v2 Custody: Zero License: MIT

Click Use this template above to launch a production-ready HTTP 402 (x402 v2) API & Model Context Protocol (MCP) Paywall in Python (FastAPI) or Node.js 18+ (ESM, zero npm dependencies).

Every payment settles 100% directly from buyer to your self-custody wallet across 7 networks (Base, Polygon, Arbitrum, BNB Chain, Ethereum, Solana, and Bitcoin Taproot) in USDC, USDT, ETH, BNB, POL, SOL, or BTC — with 0% platform cut, no Stripe/bank account, and no merchant KYC.


Included Out of the Box

File

Purpose

.well-known/x402.json

Validated x402 v2 machine-payable discovery manifest (eip155:8453 USDC + PayGate fallback)

server_fastapi.py

Runnable Python FastAPI 402 Payment Required server with PAYMENT-REQUIRED header & live on-chain verification

server_express.mjs

Zero-dependency Node.js 18+ HTTP/Express x402 v2 server & checkout helper

.mcp.json

Pre-wired MCP Server config for Cursor, Claude Code, Windsurf, and OpenCode (/paygate/mcp)

.github/workflows/paygate.yml

Automated CI check powered by EzequielLech/paygate-usdt@v2.8.1


Related MCP server: x402-mcp

60-Second Quickstart

1. Configure Your Self-Custody Wallet

Set your EVM (0x...), Solana, or Bitcoin Taproot (bc1p...) payout address:

export PAYGATE_MERCHANT_WALLET="0xYourSelfCustodyWalletAddress"
export PAYGATE_PRICE_USD="5.00"
export PAYGATE_NETWORK="base"

Also update payTo in .well-known/x402.json and merchant-wallet in .github/workflows/paygate.yml.

2A. Run the Node.js 18+ Paywall Server (Zero Dependencies)

node server_express.mjs --self-test
node server_express.mjs

2B. Run the Python FastAPI Paywall Server

pip install -r requirements.txt
python server_fastapi.py --self-test
python server_fastapi.py

3. Test the HTTP 402 Payment Required Flow

curl -i http://localhost:8000/api/premium-alpha

Unpaid callers receive HTTP/1.1 402 Payment Required, a Base64-encoded PAYMENT-REQUIRED header compatible with autonomous x402 agents, and a 1-Click 7-chain checkoutUrl for human buyers. Once settled on-chain, passing X-PayGate-Invoice: inv_... unlocks HTTP 200 OK.


Embed In-Page Glassmorphic Crypto Checkout on Any Website

Drop two lines into any HTML, Next.js, Astro, or React landing page to open an in-page 7-chain crypto checkout modal:

<script src="https://chainguard-studio-production.up.railway.app/paygate/widget.js" defer></script>
<a href="#" data-paygate data-merchant="0xYourWallet" data-amount="29" data-network="base" data-title="Pro API Access">
  Pay $29 in Crypto (0% Fee)
</a>

Production Upgrades & Managed Plans

Self-hosted verification and your first 3 hosted cloud settlements are 100% free. Scale up anytime with instant on-chain activation:

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Non-custodial payment engine for AI agents supporting BTC, ETH, USDT, USDC, XRP, XMR, and ZEC. Exposes wallet, invoice, and payment tools over MCP with per-agent spend limits, plus x402 pay-per-call support.
      59 npm
      Business Source 1.1
    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for the x402 protocol that lets AI agents discover and call payment-gated HTTP APIs automatically.
      Apache 2.0