Skip to main content

Crate r402_evm

Crate r402_evm 

Source
Expand description

EIP-155 (EVM) chain support for the x402 payment protocol.

This crate provides implementations of the x402 payment protocol for EVM chains with the “exact” payment scheme based on ERC-3009 transferWithAuthorization.

§Features

  • CAIP-2 Addressing: Uses CAIP-2 chain IDs (e.g., eip155:8453) for chain identification
  • ERC-3009 Payments: Gasless token transfers using transferWithAuthorization
  • Smart Wallet Support: EIP-1271 for deployed wallets, EIP-6492 for counterfactual wallets
  • Multiple Signers: Round-robin signer selection for load distribution
  • Nonce Management: Automatic nonce tracking with pending transaction awareness

§Architecture

The crate is organized into several modules:

  • chain - Core EVM chain types, providers, and configuration
  • signer / permit2 / asset / signature - primitives shared by every scheme
  • exact - EIP-155 “exact” payment scheme
  • upto - EIP-155 “upto” payment scheme (Permit2, usage-based)
  • auth_capture - authorize / capture / charge (commerce-payments escrow)
  • batch_settlement - capital-backed channel vouchers

§Feature Flags

  • server - Server-side price tag generation
  • client - Client-side payment signing
  • facilitator - Facilitator-side payment verification and settlement
  • telemetry - OpenTelemetry tracing support

Re-exports§

pub use error::Eip155ExactError;facilitator
pub use asset::AssetTransferMethod;
pub use asset::VALIDATOR_ADDRESS;
pub use auth_capture::Eip155AuthCapture;
pub use auth_capture::Eip155AuthCaptureFacilitator;facilitator
pub use auth_capture::Eip155AuthCaptureClient;client
pub use auth_capture::sign_auth_capture;client
pub use batch_settlement::Eip155BatchSettlement;
pub use batch_settlement::ChannelStore;facilitator
pub use batch_settlement::Eip155BatchSettlementFacilitator;facilitator
pub use batch_settlement::MemoryChannelStore;facilitator
pub use batch_settlement::compute_channel_id;facilitator
pub use batch_settlement::Eip155BatchSettlementClient;client
pub use batch_settlement::sign_voucher;client
pub use batch_settlement::sign_voucher_payload;client
pub use eip2612::EIP2612_GAS_SPONSORING_KEY;
pub use eip2612::EIP2612_GAS_SPONSORING_VERSION;
pub use eip2612::Eip2612ParseError;
pub use eip2612::Eip2612SignedPermit;
pub use erc20_approval::ERC20_APPROVAL_GAS_SPONSORING_KEY;
pub use erc20_approval::ERC20_APPROVAL_GAS_SPONSORING_VERSION;
pub use erc20_approval::Erc20ApprovalGasSponsoringInfo;
pub use erc20_approval::Erc20ApprovalParseError;
pub use exact::Eip155Exact;
pub use exact::client::Eip155ExactClient;client
pub use exact::client::Eip155ExactClientBuilder;client
pub use permit2::PERMIT2_ADDRESS;
pub use permit2::Permit2TokenPermissions;
pub use permit2::Permit2Approver;client
pub use permit2::permit2_allowance_calldata;client
pub use permit2::permit2_approval_calldata;client
pub use signature::StructuredSignatureFormatError;facilitator
pub use signer::SignerLike;client
pub use upto::Eip155Upto;
pub use upto::client::Eip155UptoClient;client
pub use upto::client::Eip2612SigningParams;client
pub use upto::client::sign_eip2612_permit;client

Modules§

asset
Shared EVM transfer-method and validator constants.
auth_capture
EIP-155 auth-capture scheme (Base commerce-payments escrow).
batch_settlement
EIP-155 batch-settlement scheme (request-path voucher accounting).
chain
EVM chain support for x402 payments via EIP-155.
eip2612
EIP-2612 gas-sponsoring extension wire types (exact + upto).
erc20_approval
erc20ApprovalGasSponsoring extension wire types.
errorfacilitator
Shared EVM facilitator errors (exact and upto).
exact
EIP-155 “exact” payment scheme implementation.
permit2
Canonical Uniswap Permit2 address, wire permissions, and client auto-approve.
signaturefacilitator
Shared EOA / EIP-1271 / EIP-6492 signature parsing and payment time windows.
signerclient
Alloy signer abstraction used by every EVM scheme client.
upto
EIP-155 “upto” payment scheme implementation.

Structs§

USDC
Ergonomic accessors for USDC token deployments on well-known EVM chains.
USDM
Ergonomic accessors for USDM (MegaUSD) token deployments on EVM chains.

Constants§

EVM_DEFAULT_CLOCK_SKEW_TOLERANCE_SECS
Default clock-skew tolerance (seconds) applied to EIP-712 time-window checks.

Statics§

EVM_NETWORKS
Well-known EVM (EIP-155) networks with their names and CAIP-2 identifiers.

Functions§

usdc_evm_deployment
Returns the USDC deployment for a specific EVM chain, if known.
usdc_evm_deployments
Returns all known USDC deployments on EVM chains.
usdm_evm_deployment
Returns the USDM deployment for a specific EVM chain, if known.
usdm_evm_deployments
Returns all known USDM deployments on EVM chains.