@make-software/casper-x402
v1.0.0
Published
x402 Payment Protocol Casper Implementation for JavaScript
Readme
@make-software/casper-x402
A TypeScript implementation of the x402 payment protocol for the Casper Network. It adds Casper as a supported network to the x402 ecosystem so HTTP APIs can require micropayments settled on-chain using CEP-18 tokens authorized via EIP-712 signatures.
This package is published as @make-software/casper-x402.
What is x402?
x402 is an open standard for internet-native payments over HTTP. When a client requests a paid resource:
- The resource server responds with
402 Payment RequiredplusPaymentRequirementsdescribing accepted networks, schemes, prices and assets. - The client builds a
PaymentPayload— an EIP-712 signed authorization — and replays the request with aPAYMENT-SIGNATUREheader. - The resource server forwards the payload to a facilitator for verification and, on success, for on-chain settlement.
- The facilitator submits a Casper
transfer_with_authorizationdeploy to the CEP-18 contract and waits for confirmation. - The resource server returns the protected response.
This package implements the exact scheme on the casper:* CAIP-2 family, backed by the casper-ecosystem/casper-eip-712 typed-data specification.
Installation
npm install @make-software/casper-x402Peer / transitive dependencies include @x402/core, casper-js-sdk and @casper-ecosystem/casper-eip-712.
Entry points
The package exposes a root entry with signer helpers and utilities, plus three subpaths for the exact scheme.
| Entry | Purpose |
| --- | --- |
| @make-software/casper-x402 | Signers, types, constants and utilities |
| @make-software/casper-x402/exact/client | ExactCasperScheme for clients |
| @make-software/casper-x402/exact/server | ExactCasperScheme and registration for resource servers |
| @make-software/casper-x402/exact/facilitator | ExactCasperScheme and registration for facilitators |
Network identifiers
Casper networks use CAIP-2 format:
casper:casper— Casper Mainnetcasper:casper-test— Casper Testnet
These are exported as NETWORK_CASPER_MAINNET and NETWORK_CASPER_TESTNET from the package root.
Examples
Runnable examples are available in the casper-x402 monorepo under examples/.
License
This project is licensed under the Apache License 2.0.
