x402 payments in Rust: verify, settle, and monitor payments over HTTP 402 flows
x402-rs is an established Rust project in the AI payments / x402 ecosystem. It currently has 280 GitHub stars and 165 forks.
x402 payments in Rust: verify, settle and monitor payments over HTTP 402 flows. The name says it exactly — this is the Rust-native implementation of the protocol.
Rust is the natural home for the performance-critical middle of the x402 stack: facilitators and proxies that verify thousands of payments per second, where latency directly costs money. x402-rs gives that tier a first-class implementation instead of a wrapper around the TypeScript reference, and its monitor tooling helps operate settlement in production.
Best for: teams building facilitators, gateways or high-throughput paid APIs in Rust.
A comprehensive Rust toolkit for the x402 protocol, enabling blockchain payments directly through HTTP using the native
402 Payment Requiredstatus code.
x402-rs is a modular, production-ready implementation of the x402 protocol with support for multiple blockchains (EVM, Solana, Aptos, ..) and protocol versions (V1 and V2).
| Crate | Badges | Description |
|---|---|---|
x402-types |
Core protocol types, facilitator traits, and utilities. Foundation for all x402 implementations. | |
x402-axum |
Axum middleware for protecting routes with x402 payments. | |
x402-reqwest |
Reqwest middleware for transparent x402 payment handling. | |
x402-facilitator-local |
Local facilitator implementation for payment verification and settlement. |
| Crate | Badges | Description |
|---|---|---|
x402-chain-eip155 |
EVM/EIP-155 chain support (Ethereum, Base, Polygon, etc.) | |
x402-chain-solana |
Solana blockchain support | |
x402-chain-aptos |
⚠️ Git-only | Aptos blockchain support (requires git dependency) |
| Crate | Description |
|---|---|
x402-facilitator |
Production-ready facilitator server binary (not published to crates.io) |
The x402 protocol is a proposed standard for making blockchain payments directly through HTTP using the native 402 Payment Required status code.
How it works:
This enables seamless pay-per-use transactions without requiring clients to manage blockchain interactions directly.
Use x402-axum to gate your routes behind on-chain payments:
use alloy_primitives::address;
use axum::{Router, routing::get};
use x402_axum::X402Middleware;
use x402_chain_eip155::V2Eip155Exact;
use x402_types::networks::USDC;
let x402 = X402Middleware::new("http://facilitator.example.com");
let app = Router::new().route(
"/paid-content",
get(handler).layer(
x402.with_price_tag(V2Eip155Exact::price_tag(
address!("0xYourAddress"),
USDC::base_sepolia().amount(10u64),
))
),
);
See x402-axum documentation for more details.
Use x402-reqwest to automatically handle x402 payments:
use x402_reqwest::{ReqwestWithPayments, ReqwestWithPaymentsBuild, X402Client};
use x402_chain_eip155::V2Eip155ExactClient;
use alloy_signer_local::PrivateKeySigner;
use std::sync::Arc;
use reqwest::Client;
let signer: Arc<PrivateKeySigner> = Arc::new("0x...".parse()?);
let x402_client = X402Client::new()
.register(V2Eip155ExactClient::new(signer));
let client = Client::new()
.with_payments(x402_client)
.build();
let res = client
.get("https://example.com/protected")
.send()
.await?;
See x402-reqwest documentation for more details.
Prebuilt Docker images are available at GitHub Container Registry:
docker run -v $(pwd)/config.json:/app/config.json -p 8080:8080 ghcr.io/x402-rs/x402-facilitator
For custom facilitator implementations, see the Build Your Own Facilitator guide.
For full facilitator configuration and deployment details, see the x402-facilitator README.
| Milestone | Description | Status |
|---|---|---|
| Facilitator for Base USDC | Payment verification and settlement service, enabling real-time pay-per-use transactions for Base chain. | ✅ Complete |
| Metrics and Tracing | Expose OpenTelemetry metrics and structured tracing for observability, monitoring, and debugging | ✅ Complete |
| Server Middleware | Provide ready-to-use integration for Rust web frameworks such as axum and tower. | ✅ Complete |
| Client Library | Provide a lightweight Rust library for initiating and managing x402 payment flows from Rust clients. | ✅ Complete |
| Solana Support | Support Solana chain. | ✅ Complete |
| Protocol v2 Support | Support x402 protocol version 2 with improved payload structure. | ✅ Complete |
| Multiple chains and multiple tokens | Support various tokens and EVM compatible chains. | ✅ Complete |
| Axum Middleware v2 Support | Full x402 protocol v2 support in x402-axum with multi-chain, multi-scheme architecture. | ✅ Complete |
| Reqwest Client v2 Support | Full x402 protocol v2 support in x402-reqwest with multi-chain, multi-scheme architecture. | ✅ Complete |
| Build your own facilitator hooks | Pre/post hooks for analytics, access control, and auditability. | 🔜 Planned |
| Bazaar Extension | Marketplace integration for discovering and purchasing x402-protected resources. | 🔜 Planned |
| Gasless Approval Flow | Support for Permit2 and ERC20 approvals to enable gasless payment authorization. | 🔜 Planned |
| Upto Scheme | Payment scheme supporting "up to" amount payments with flexible pricing. | 🔜 Planned |
| Deferred Scheme | Payment scheme supporting deferred settlement and payment scheduling. | 🔜 Planned |
Feel free to open issues or pull requests to improve x402 support in the Rust ecosystem.
Agent behavior that compiles
An open SDK for agentic payments. Let AI agents make payments, hold funds, and move money across chains with policy enforcement and human approval built in.
The self-improving LLM router that optimize your agentic workflows with every runs, works with any harnesses, any models, any loops.
Production-ready x402 facilitator server.
Rust SDK for the x402 payment protocol.
An operating system built for AI agents — talk to your NixOS server instead of SSH-ing in. Typed, audited tool access with atomic rollback on every change. Research-grade; run it on a disposable box, not production.