Kaspa x402

1.0.1 released · Standard and SDK · Release details

Kaspa x402

Kaspa x402 is a proposed native Kaspa binding for x402, the HTTP 402 payment protocol. It lets HTTP APIs and MCP tools charge native KAS per request, and lets servers verify and settle those payments directly against the Kaspa network.

Security and use

This SDK supports mainnet configuration. It has undergone extensive AI-assisted security review, and all four payment profiles were tested on funded Testnet. It has not received an independent third-party security audit. Undiscovered bugs may result in loss of funds. Provided as is, without warranty. Review and testing details.

Status

What is x402

x402 is an open protocol that turns the HTTP 402 Payment Required status code into a machine-payable flow: a server answers an unpaid request with a 402 carrying a machine-readable offer, the client retries with a signed payment payload, and the server verifies the payment, settles it, and serves the response. The same primitives work over HTTP headers and MCP _meta fields, so paid APIs and tools are usable by autonomous agents. See x402.org.

What is Kaspa

Kaspa is a proof-of-work layer 1 whose blockDAG consensus produces blocks at sub-second cadence with native UTXO semantics. See kaspa.org.

Why a native Kaspa binding

The claims below are engineering rationale, each specified or backed by testnet evidence. None of them is a mainnet claim.

Payment schemes

The binding ships two schemes with different settlement shapes.

exact — fixed-price one-shot native transfer under kaspa-exact-v2. standard-native is the default ordinary KAS transfer. The optional additive profile consumes and recreates a reusable merchant KIP-10 head; the successor increase is the sole exact payment, with no second merchant output and no per-offer inventory reservation.

The SDK also includes the optional hash-chain-additive exact profile with OTP-style one-time signing grants. The payer independently broadcasts a payment that increases the head and advances its hash guard. Try it in the browser demo on Testnet.

{
  "scheme": "exact",
  "network": "kaspa:<network>",
  "asset": "KAS",
  "amount": "<sompi>",
  "extra": {
    "binding": "kaspa-exact-v2",
    "profile": "standard-native",
    "paymentFlow": "upfront"
  }
}

batch-settlement — repeated requests with a payer-approved fixed charge per invocation against a KIP-20 escrow lane. Its lifecycle is singleton genesis → repeated partial claims → top-up → refund. The current outpoint and V rotate while the stable covenant ID and lifetime A/S/T remain recoverable; R is the advertised minimum successor reserve. Spec: kaspa-batch-settlement-v3.

{
  "scheme": "batch-settlement",
  "network": "kaspa:<network>",
  "asset": "KAS",
  "amount": "<fixed per-request sompi>",
  "extra": {
    "binding": "kaspa-escrow-v3",
    "templateId": "kaspa-x402-escrow-v5"
  }
}

Start here

Packages

Install the stable SDK using the exact versions below, or npm latest.

npm install @kaspa-x402/core@1.0.1 @kaspa-x402/covenant@1.0.1 @kaspa-x402/client@1.0.1 @kaspa-x402/server@1.0.1
PackageVersionRegistrySource
@kaspa-x402/client1.0.1npmsource
@kaspa-x402/core1.0.1npmsource
@kaspa-x402/covenant1.0.1npmsource
@kaspa-x402/server1.0.1npmsource

Machine-readable: packages.json, site-manifest.json.