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 (r402-evm, r402-svm).
§Modules
wire— On-the-wire JSON types (versioned:wire::v2)facilitator—Facilitatortrait andDynFacilitatorerasurescheme— Payment scheme registry andsealedbuilder traitshooks— Lifecycle hooks forverify/settleextensions— Extension framework for x402 protocol extensionspayment—Payment<State>typestate for compile-time lifecycle safetychain— CAIP-2 chain identifiers, address, provider abstractionsamount— Human-readable currency amount parsing ("$0.01"etc.)error— Layered error types (FacilitatorError,VerificationError, …)
§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. | |
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::ResourceServer;pub use resource_server::WirePaymentPayload;pub use error::ClientError;pub use error::FacilitatorError;pub use error::SettlementError;pub use error::VerificationError;pub use error_reason::AsPaymentProblem;pub use error_reason::ErrorReason;pub use error_reason::PaymentProblem;pub use facilitator::BoxFuture;pub use facilitator::DynFacilitator;pub use facilitator::Facilitator;pub use hooks::DynFacilitatorHooks;pub use hooks::FacilitatorHooks;pub use hooks::FailureRecovery;pub use hooks::HookDecision;pub use hooks::HookedFacilitator;pub use hooks::SettleContext as HookSettleContext;pub use hooks::VerifyContext as HookVerifyContext;
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.
- error
- Layered error types for x402 facilitator operations.
- error_
reason - Machine-readable error codes used in x402 verify/settle responses.
- extensions
- Extension framework for x402 protocol extensions.
- facilitator
- Unified asynchronous interface for x402 payment facilitators.
- hooks
- Lifecycle hooks for facilitator verify / settle operations.
- metrics
metrics - Stable metric names emitted by the r402 stack.
- payment
- Typestate lifecycle for a single x402 payment.
- 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.