--- id: x402 version: "2.19.0" license: MIT license_treatment: permissive maintenance: active --- # x402 — x402 Payment Protocol SDK for Python License: permissive · Maintenance: active · Downloads: 180.1K/mo ## What it is and what it does x402 is a Python SDK implementing the x402 payment protocol, a standard for HTTP 402 (Payment Required) responses that bridges web services with blockchain payments. It provides three main roles—client (initiates payments), resource server (enforces payment requirements), and facilitator (settles transactions)—each with async and sync variants. The protocol is transport-agnostic and supports multiple blockchains: EVM networks (Ethereum, Base, etc.), Solana, and TON/TVM. You use it to add cryptographic payment verification to web services without building blockchain integration from scratch. Register payment schemes for your target networks, define payment requirements (amount, recipient, network), and the SDK handles signature generation, verification, and settlement. It integrates with FastAPI and Flask via middleware, works with httpx or requests for HTTP clients, and auto-detects async vs. sync contexts. The library is young (first release February 2025) but actively maintained and designed for declarative configuration via policies and lifecycle hooks. Use it for: - Protect API endpoints with blockchain-backed micropayments (e.g., charge per API call in USDC on Base). - Build a content delivery service that requires payment in Solana before serving resources. - Implement a facilitator node that verifies and settles x402 payments across multiple blockchains. - Add pay-per-use billing to a FastAPI service with EVM wallet signatures. - Create a cross-chain payment gateway supporting EVM, Solana, and TON in a single codebase. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Implements the x402 payment protocol with transport-agnostic client, server, and facilitator components supporting EVM, Solana, and TON blockchains via both async and sync APIs. Yes, if you are building a service that needs HTTP 402 payment protocol support with blockchain settlement. The SDK is actively maintained, has low install friction, and covers the major blockchains. However, the Alpha status and recent first release (February 2025) mean the protocol and API may still evolve—use in production only after reviewing the security model and testing thoroughly with your blockchain of choice. ## Install pip install x402 uv add x402 poetry add x402 ## Installing x402 Before you install: Low friction: pure Python wheel with only three runtime dependencies (nest-asyncio, pydantic, typing-extensions). Active maintenance—released 3 days ago with 6502 repository stars and continuous commits. License in practice: MIT license (permissive) places no restrictions on commercial or proprietary use, modification, or distribution. Quickstart: pip install x402[evm] from x402 import x402Client from x402.mechanisms.evm.exact import ExactEvmScheme client = x402Client() client.register("eip155:*", ExactEvmScheme(signer=my_signer)) payload = await client.create_payment_payload(payment_required) Requires Python 3.10+. Optional extras (httpx, requests, fastapi, flask, evm, svm, tvm) must be installed separately depending on your transport and blockchain choice. Verify before relying: - Whether the protocol is finalized or still evolving (Alpha status suggests ongoing changes). - Production readiness and security audit status for blockchain payment handling. - Specific performance characteristics and throughput limits for payment verification. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 180.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags http 402 payment protocol, blockchain payment sdk, evm solana ton payments, async payment client server, x402 protocol implementation, blockchain-payments, http-402-protocol, async-sync-dual [View on SkillFed](https://skillfed.io/packages/x402) · [View on PyPI](https://pypi.org/project/x402/)