Skip to main content

Crate r402

Crate r402 

Source
Expand description

Core types for the x402 payment protocol.

This crate provides the foundational types used throughout the x402 ecosystem for implementing HTTP 402 Payment Required flows. It is designed to be blockchain-agnostic, with chain-specific implementations provided by separate crates.

§Overview

The x402 protocol enables micropayments over HTTP by leveraging the 402 Payment Required status code. When a client requests a paid resource, the server responds with payment requirements. The client signs a payment authorization, which is verified and settled by a facilitator.

§Modules

  • amount - Human-readable currency amount parsing
  • chain - Blockchain identifiers and provider abstractions (CAIP-2 chain IDs)
  • facilitator - Core trait for payment verification and settlement
  • hooks - Lifecycle hooks for facilitator verify/settle operations
  • networks - Registry of well-known blockchain networks
  • proto - Wire format types, encoding utilities, and timestamps
  • scheme - Payment scheme system for extensible payment methods

§Feature Flags

  • telemetry - Enables tracing instrumentation for debugging and monitoring

Modules§

amount
Human-readable currency amount parsing.
chain
Blockchain-specific types and providers for x402 payment processing.
facilitator
Core trait and error type for x402 payment facilitators.
hooks
Lifecycle hooks for x402 facilitator operations.
networks
Blockchain network identification.
proto
Protocol types for x402 payment messages.
scheme
Payment scheme system for x402.