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:mainnetandnear:testnet - NEP-141 Payments: exact
ft_transferof 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 generationclient— client-side delegate signingfacilitator— facilitator-side payment verification and settlementtelemetry—tracinginstrumentation
Re-exports§
pub use chain::NearJsonRpc;clientorfacilitatorpub use chain::NearChainProvider;facilitatorpub use chain::NearRelayer;facilitatorpub use exact::NearExact;pub use exact::client::NearExactClient;clientpub use exact::client::NearSigner;client
Modules§
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(30TGas). - 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.