@erudite-intelligence/x402-algo
v1.0.0
Published
x402 exact payment scheme implementation for Algorand ALGO
Maintainers
Readme
@erudite-intelligence/x402-algo
x402
exactpayment scheme implementation for Algorand ALGO.
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 Algorand network. It enables HTTP 402-based micropayments using native ALGO payment transactions.
- CAIP-2 Network ID:
algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k - Unit: microAlgos (1 ALGO = 1,000,000 microAlgos)
- Signing: Ed25519 via algosdk
- Verification: Algonode.io (Algod + Indexer)
Installation
npm install @erudite-intelligence/x402-algoUsage
Client — Create a Payment
import { createPayment } from "@erudite-intelligence/x402-algo";
const paymentHeader = await createPayment({
senderMnemonic: "abandon abandon ... about",
recipientAddress: "AAAAA...",
amountMicroAlgos: "1000000", // 1 ALGO
network: "mainnet",
});Server — Verify & Settle
import { verifyAndSettle } from "@erudite-intelligence/x402-algo";
const result = await verifyAndSettle({
paymentHeader: req.headers["x-payment"],
expectedRecipient: "AAAAA...",
expectedAmountMicroAlgos: "1000000",
network: "mainnet",
});
if (result.success) {
console.log("Settled:", result.txId, "Round:", result.confirmedRound);
}Security
- Replay protection: In-memory Map with 1-hour TTL. Multi-instance deployments MUST use Redis/DB.
- Fail-closed: If balance query or API call fails, the payment is REJECTED.
- Round validation: Transaction validity is checked against current network round.
- On-chain field verification: Transaction outputs are decoded and checked against expected values.
License
MIT — Erudite Intelligence LLC
