@erudite-intelligence/x402-dot
v1.0.0
Published
x402 exact payment scheme implementation for Polkadot DOT
Maintainers
Readme
@erudite-intelligence/x402-dot
x402
exactpayment scheme implementation for Polkadot DOT.
Part of the EruditePay x402 multi-chain payment infrastructure by Erudite Intelligence LLC.
Overview
This package implements the x402 protocol's exact payment scheme for the Polkadot relay chain. It enables HTTP 402-based micropayments using native DOT transfers via balances.transferKeepAlive.
- CAIP-2 Network ID:
polkadot:91b171bb158e2d3848fa23a9f1c25182 - Unit: planck (1 DOT = 10,000,000,000 planck)
- Signing: Sr25519 / Ed25519 via @polkadot/keyring
- Verification: Polkadot RPC + Subscan API
Installation
npm install @erudite-intelligence/x402-dotUsage
Client — Create a Payment
import { createPayment } from "@erudite-intelligence/x402-dot";
const paymentHeader = await createPayment({
senderSeed: "bottom drive obey lake curtain smoke basket hold race lonely fit walk",
recipientAddress: "15oF4uVJwmo4TdGW7VfQxNLavjCXviqWrztPu3cCLCf4B7p",
amountPlanck: "10000000000", // 1 DOT
network: "mainnet",
});Server — Verify & Settle
import { verifyAndSettle } from "@erudite-intelligence/x402-dot";
const result = await verifyAndSettle({
paymentHeader: req.headers["x-payment"],
expectedRecipient: "15oF4uVJwmo4TdGW7VfQxNLavjCXviqWrztPu3cCLCf4B7p",
expectedAmountPlanck: "10000000000",
network: "mainnet",
});
if (result.success) {
console.log("Settled:", result.txHash);
}Security
- Replay protection: In-memory Map with 1-hour TTL. Multi-instance deployments MUST use Redis/DB.
- Fail-closed: If balance query or RPC call fails, the payment is REJECTED.
- Mortal transactions: Uses mortal era to enforce transaction expiry on-chain.
License
MIT — Erudite Intelligence LLC
