Expand description
§r402-core
Core types, traits, and wire formats for the x402 payment protocol.
This crate is blockchain-agnostic. It defines the shared data model used by
client, server, and facilitator implementations across every chain. Chain
specific behavior lives in sibling crates — see crates/README.md.
§Modules
wire— On-the-wire JSON types (offer, facilitator RPC, codecs) and settlement overridesfacilitator—Facilitatortrait,DynFacilitatorerasure, verify/settle hooksscheme— Payment scheme registry and builder traitsextensions— Extension framework for x402 protocol extensionsclient—PaymentClientorchestrationresource_server— Transport-agnostic verify → execute → settlechain— CAIP-2 chain identifiers, address, provider abstractionsamount— Human-readable currency amount parsing ("$0.01"etc.)error— Layered errors and machine-readableErrorReasonwire codes
§Feature Flags
| Flag | Default | Effect |
|---|---|---|
telemetry | Enable tracing instrumentation | |
cache | Enable moka-backed TTL caches | |
ext-bazaar | Enable the bazaar resource discovery ext. | |
ext-payment-id | Enable the payment-identifier idempotency. | |
ext-eip2612 | Enable EIP-2612 gas-sponsoring extra. | |
ext-erc20-approval | Enable ERC-20 approval gas-sponsoring extra. | |
metrics | Enable the metrics facade counters. | |
all-extensions | Enable every built-in extension | |
full | Enable every feature |
§License
Licensed under either of MIT or Apache-2.0, at your option.
Re-exports§
pub use resource_server::AfterVerifyDecision;pub use resource_server::BeforeOpDecision;pub use resource_server::CancelReason;pub use resource_server::CancellationGuard;pub use resource_server::DynResourceServerHooks;pub use resource_server::PaymentHookContext;pub use resource_server::ResourceServer;pub use resource_server::ResourceServerHooks;pub use resource_server::SettleResultContext;pub use resource_server::SkipHandlerDirective;pub use resource_server::VerifiedPaymentCanceledContext;pub use resource_server::VerifyPaymentOutcome;pub use resource_server::VerifyResultContext;pub use resource_server::WirePaymentPayload;pub use client::ClientHooks;pub use client::CreatedPayment;pub use client::DynClientHooks;pub use client::PaymentClient;pub use client::PaymentCreationContext;pub use client::PaymentResponseContext;pub use client::PaymentResponseResult;pub use error::AsPaymentProblem;pub use error::ClientError;pub use error::ErrorReason;pub use error::FacilitatorError;pub use error::PaymentProblem;pub use error::SettlementError;pub use error::VerificationError;pub use facilitator::BoxFuture;pub use facilitator::DynFacilitator;pub use facilitator::DynFacilitatorHooks;pub use facilitator::Facilitator;pub use facilitator::FacilitatorHooks;pub use facilitator::FailureRecovery;pub use facilitator::HookDecision;pub use facilitator::HookedFacilitator;pub use wire::DEFAULT_ASSET_DECIMALS;pub use wire::SettlementOverrideError;pub use wire::SettlementOverrides;pub use wire::asset_decimals_from_extra;pub use wire::resolve_settlement_override_amount;
Modules§
- amount
- Human-readable currency amount parsing.
- cache
cache - Shared cache primitives used by facilitator implementations.
- chain
- Blockchain-specific types and providers for x402 payment processing.
- client
- Client-side payment orchestration (official
x402Client, V2-only). - error
- Layered error types for x402 facilitator operations.
- extensions
- Extension framework for x402 protocol extensions.
- facilitator
- Unified asynchronous interface for x402 payment facilitators.
- metrics
metrics - Stable metric names emitted by the r402 stack.
- resource_
server - Resource-server orchestration shared by HTTP and MCP transports.
- scheme
- Scheme identifiers, registry, and the extensible payment scheme system.
- wire
- On-the-wire JSON types for the x402 protocol.