Expand description
Casper chain support for the x402 payment protocol.
This crate implements the x402 “exact” payment scheme for the
Casper Network, settling in wCSPR — a CEP-18
token — through the contract’s transfer_with_authorization entry point.
§Features
- CAIP-2 Addressing:
casper:casper(mainnet) andcasper:casper-test(testnet) - CEP-18 Payments: token transfers authorised by an EIP-712
TransferWithAuthorizationsignature, relayed and gas-paid by the facilitator - Exact Mote Arithmetic: CSPR has 9 decimals; every conversion is
integer-only and sub-mote precision is a typed error, never a silent
truncation (see
Motes) - Key Validation: tagged Casper addressable keys (
00account hash,01hash) and public keys (01ed25519,02secp256k1) - Facilitator Client:
/verify,/settle, and/supportedagainst the hosted Casper facilitator, overridable via config or environment
§Architecture
The crate mirrors the layout of the sibling chain crates:
chain— Casper chain types (references, addresses, deployments)exact— the Casper “exact” payment schememotes— exact 9-decimal base-unit arithmetichex— minimal hex codec for Casper wire values
§Feature Flags
server— server-side price tag generationclient— client-side authorisation assemblyfacilitator— facilitator client for verify/settle/supportedtelemetry— tracing instrumentation
§Example
use r402_casper::chain::Address;
use r402_casper::{CasperExact, WCSPR};
let pay_to: Address = "00fedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321"
.parse()
.unwrap();
// 1.5 wCSPR, expressed exactly in motes.
let tag = CasperExact::price_tag(pay_to, WCSPR::casper_test().amount(1_500_000_000));
assert_eq!(tag.requirements.network.to_string(), "casper:casper-test");Re-exports§
pub use exact::CasperExact;pub use exact::facilitator::ReqwestTransport;http-clientpub use exact::facilitator::CasperExactFacilitator;facilitatorpub use exact::facilitator::CasperFacilitatorConfig;facilitatorpub use exact::CasperExactClient;clientpub use exact::CasperSigner;clientpub use exact::Eip712Domain;clientpub use motes::CSPR_DECIMALS;pub use motes::MOTES_PER_CSPR;pub use motes::Motes;pub use motes::MotesParseError;
Modules§
- chain
- Casper chain support for x402 payments.
- exact
- Casper “exact” payment scheme implementation.
- hex
- Minimal, dependency-free hex helpers.
- motes
- Exact integer arithmetic for CSPR motes.
Structs§
- WCSPR
- Ergonomic accessors for wCSPR token deployments on well-known Casper chains.
Constants§
- CASPER_
DOCS_ URL - Public JSON-RPC endpoint documentation for the Casper facilitator stack.
- WCSPR_
NAME - EIP-712 domain
nameof the wCSPR CEP-18 contract. - WCSPR_
VERSION - EIP-712 domain
versionof the wCSPR CEP-18 contract.
Statics§
- CASPER_
NETWORKS - Well-known Casper networks with their names and CAIP-2 identifiers.
Functions§
- wcspr_
casper_ deployment - Returns the wCSPR deployment for a specific Casper chain, if known.
- wcspr_
casper_ deployments - Returns all known wCSPR deployments on Casper chains.