r402-casper 0.15.0

Casper chain support for the x402 payment protocol.
Documentation

r402-casper

Casper Network support for the x402 payment protocol, part of the r402 workspace.

Scope

This crate is a remote-facilitator integration:

  • Local preflight validates wire shape, accepted↔requirements consistency, mote amounts, timing, and publicKeyauthorization.from binding.
  • Cryptographic signature verification and on-chain settlement are performed by a hosted (or self-hosted) Casper x402 facilitator — default https://x402-facilitator.cspr.cloud.
  • There is no in-process Casper RPC / key-custody stack. That keeps the dependency footprint comparable to other chain crates while matching the Casper Association deployment model.

Highlights

  • Exact scheme — CEP-18 / CEP-3009 transfer_with_authorization via pre-signed EIP-712 authorizations (wCSPR on testnet built in).
  • CAIP-2 networkscasper:casper (mainnet) and casper:casper-test.
  • Exact mote arithmetic — 9 decimals; sub-mote precision is a typed error, never a silent truncation.
  • Facilitator client/verify, /settle, /supported with optional local preflight and configurable timeout.

Cargo Features

Feature Surface
client CasperExactClient (SchemeClient) + EIP-712 digest.
server Server-side PriceTag generation.
facilitator Remote facilitator client (verify / settle).
http-client Default reqwest transport (ReqwestTransport).
telemetry tracing instrumentation.
full All of the above.

Client (SchemeClient)

use r402_casper::{CasperExactClient, CasperSigner};
use r402_http::client::X402Client;

// `MyWallet: CasperSigner` supplies public_key + sign_digest.
let x402 = X402Client::new().register(CasperExactClient::new(my_wallet));

Facilitator (http-client)

use r402_casper::CasperExactFacilitator;

let facilitator = CasperExactFacilitator::hosted_http();
// or: CasperExactFacilitator::from_env_http()?;

Quick Start (server price tag)

use r402_casper::chain::Address;
use r402_casper::{CasperExact, WCSPR};

let pay_to: Address = "00fedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321"
    .parse()
    .unwrap();
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");

Override the facilitator URL with R402_CASPER_FACILITATOR_URL.

References

License

Dual-licensed under MIT and Apache-2.0.