@erudite-intelligence/x402-atom
v1.0.0
Published
x402 exact payment scheme implementation for Cosmos Hub ATOM
Maintainers
Readme
@erudite-intelligence/x402-atom
x402
exactpayment scheme implementation for Cosmos Hub ATOM.
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 Cosmos Hub. It enables HTTP 402-based micropayments using native ATOM bank/MsgSend transfers via CosmJS.
- CAIP-2 Network ID:
cosmos:cosmoshub-4 - Unit: uatom (1 ATOM = 1,000,000 uatom)
- Signing: Secp256k1 via @cosmjs/proto-signing
- Verification: Cosmos RPC (Stargate)
Installation
npm install @erudite-intelligence/x402-atomUsage
Client — Create a Payment
import { createPayment } from "@erudite-intelligence/x402-atom";
const paymentHeader = await createPayment({
senderMnemonic: "abandon abandon ... about",
recipientAddress: "cosmos1abc...",
amountUatom: "1000000", // 1 ATOM
network: "mainnet",
memo: "x402 payment",
});Server — Verify & Settle
import { verifyAndSettle } from "@erudite-intelligence/x402-atom";
const result = await verifyAndSettle({
paymentHeader: req.headers["x-payment"],
expectedRecipient: "cosmos1abc...",
expectedAmountUatom: "1000000",
network: "mainnet",
});
if (result.success) {
console.log("Settled:", result.txHash, "Height:", result.height);
}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.
- Tx hash verification: Transaction bytes are hashed (SHA-256) for replay detection before broadcast.
License
MIT — Erudite Intelligence LLC
