Skip to main content

Crate r402_core

Crate r402_core 

Source
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)
  • facilitatorFacilitator trait and DynFacilitator erasure
  • scheme — Payment scheme registry and sealed builder traits
  • hooks — Lifecycle hooks for verify/settle
  • extensions — Extension framework for x402 protocol extensions
  • paymentPayment<State> typestate for compile-time lifecycle safety
  • chain — CAIP-2 chain identifiers, address, provider abstractions
  • amount — Human-readable currency amount parsing ("$0.01" etc.)
  • error — Layered error types (FacilitatorError, VerificationError, …)

§Feature Flags

FlagDefaultEffect
telemetryEnable tracing instrumentation
cacheEnable moka-backed TTL caches
ext-bazaarEnable the bazaar resource discovery ext.
ext-payment-idEnable the payment-identifier idempotency.
all-extensionsEnable every built-in extension
fullEnable 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.
cachecache
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.
metricsmetrics
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.