Skip to main content

x402_types/
lib.rs

1//! Core types for the x402 payment protocol.
2//!
3//! This crate provides the foundational types used throughout the x402 ecosystem
4//! for implementing HTTP 402 Payment Required flows. It is designed to be
5//! blockchain-agnostic, with chain-specific implementations provided by separate crates.
6//!
7//! # Overview
8//!
9//! The x402 protocol enables micropayments over HTTP by leveraging the 402 Payment Required
10//! status code. When a client requests a paid resource, the server responds with payment
11//! requirements. The client signs a payment authorization, which is verified and settled
12//! by a facilitator.
13//!
14//! # Modules
15//!
16//! - [`chain`] - Blockchain identifiers and provider abstractions (CAIP-2 chain IDs)
17//! - [`config`] - Server configuration, CLI parsing, RPC config, and environment variable resolution
18//! - [`facilitator`] - Core trait for payment verification and settlement
19//! - [`networks`] - Registry of well-known blockchain networks
20//! - [`proto`] - Wire format types for protocol messages (V1 and V2)
21//! - [`scheme`] - Payment scheme system for extensible payment methods
22//! - [`timestamp`] - Unix timestamp utilities for payment authorization windows
23//! - [`util`] - Helper types (base64, string literals, money amounts)
24//!
25//! # Protocol Versions
26//!
27//! The crate supports two protocol versions:
28//!
29//! - **V1** ([`proto::v1`]): Original protocol using network names (e.g., "base-sepolia")
30//! - **V2** ([`proto::v2`]): Enhanced protocol using CAIP-2 chain IDs (e.g., "eip155:84532")
31//!
32//! # Feature Flags
33//!
34//! - `cli` - Enables CLI argument parsing via clap for configuration loading
35//! - `telemetry` - Enables tracing instrumentation for debugging and monitoring
36
37pub mod chain;
38pub mod config;
39pub mod facilitator;
40pub mod networks;
41pub mod proto;
42pub mod scheme;
43pub mod timestamp;
44pub mod util;