Skip to main content

Crate r402_near

Crate r402_near 

Source
Expand description

NEAR chain support for the x402 payment protocol.

This crate implements the x402 "exact" scheme for NEAR: the buyer signs a NEP-366 SignedDelegate that authorizes one NEP-141 ft_transfer, and a facilitator-sponsored relayer submits the outer transaction.

§Features

  • CAIP-2 Addressing: near:mainnet and near:testnet
  • NEP-141 Payments: exact ft_transfer of a token (USDC by default)
  • NEP-366 Meta-transactions: client signs a delegate; the relayer pays gas
  • In-process facilitator: JSON-RPC verify and settle

§Feature Flags

  • server — server-side price tag generation
  • client — client-side delegate signing
  • facilitator — facilitator-side payment verification and settlement
  • telemetrytracing instrumentation

Re-exports§

pub use chain::NearJsonRpc;client or facilitator
pub use chain::NearChainProvider;facilitator
pub use chain::NearRelayer;facilitator
pub use exact::NearExact;
pub use exact::client::NearExactClient;client
pub use exact::client::NearSigner;client

Modules§

chain
NEAR chain support for x402 payments.
exact
NEAR "exact" payment scheme implementation.

Structs§

USDC
Ergonomic accessors for USDC token deployments on well-known NEAR chains.

Constants§

DEFAULT_FT_TRANSFER_GAS
Default gas attached to the delegated ft_transfer (30 TGas).
DEFAULT_MAX_SPONSORED_GAS
Conservative cap on sponsored gas to protect relayers (100 TGas).
DEFAULT_TOKEN_DECIMALS
Default USDC decimal precision.
EMPTY_CONTRACT_CODE_HASH
Base58 representation of an all-zero 32-byte code hash.
ESTIMATED_BLOCK_SECONDS
Deterministic timeout mapping (spec §5): estimatedBlockSeconds = 1.
FT_TRANSFER_METHOD
NEP-141 transfer method.
NONCE_RANGE_MULTIPLIER
NEAR delegate-action nonce upper-bound multiplier (ACCESS_KEY_NONCE_RANGE_MULTIPLIER).
ONE_YOCTO
NEP-141 requires exactly 1 yoctoNEAR attached to ft_transfer.

Statics§

NEAR_NETWORKS
Well-known NEAR networks with their names and CAIP-2 identifiers.

Functions§

timeout_blocks
timeoutBlocks = max(1, ceil(maxTimeoutSeconds / estimatedBlockSeconds)).
usdc_near_deployment
Returns the USDC deployment for a specific NEAR chain, if known.
usdc_near_deployments
Returns all known USDC deployments on NEAR chains.