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 — see crates/README.md.

§Modules

  • wire — On-the-wire JSON types (offer, facilitator RPC, codecs) and settlement overrides
  • facilitatorFacilitator trait, DynFacilitator erasure, verify/settle hooks
  • scheme — Payment scheme registry and builder traits
  • extensions — Extension framework for x402 protocol extensions
  • clientPaymentClient orchestration
  • resource_server — Transport-agnostic verify → execute → settle
  • chain — CAIP-2 chain identifiers, address, provider abstractions
  • amount — Human-readable currency amount parsing ("$0.01" etc.)
  • error — Layered errors and machine-readable ErrorReason wire codes

§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.
ext-eip2612Enable EIP-2612 gas-sponsoring extra.
ext-erc20-approvalEnable ERC-20 approval gas-sponsoring extra.
metricsEnable the metrics facade counters.
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::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.
cachecache
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.
metricsmetrics
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.