@erudite-intelligence/x402-xmr
v1.0.0
Published
x402 exact payment scheme implementation for Monero (XMR)
Maintainers
Readme
@erudite-intelligence/x402-xmr
x402 exact payment scheme implementation for Monero (XMR).
First-of-kind x402 implementation for the Monero network.
Architecture Note
Monero cannot sign transactions offline in JS like Bitcoin-family coins.
This package uses the monero-wallet-rpc to create transfers and provides
the tx_key as cryptographic proof. The server verifies via check_tx_key
on the daemon RPC — no wallet needed on the facilitator side.
Install
npm install @erudite-intelligence/x402-xmrUsage
Client (create payment)
Requires a running monero-wallet-rpc instance:
import { createPayment } from "@erudite-intelligence/x402-xmr";
const paymentHeader = await createPayment({
walletRpcUrl: "http://127.0.0.1:18082/json_rpc",
recipientAddress: "4...",
amount: "0.1",
});
// Set as X-PAYMENT headerServer (verify & settle)
Requires access to a Monero daemon RPC:
import { verifyAndSettle } from "@erudite-intelligence/x402-xmr";
const result = await verifyAndSettle({
paymentHeader: req.headers["x-payment"],
expectedRecipient: "4...",
expectedAmountPiconero: "100000000000",
daemonRpcUrl: "http://127.0.0.1:18081/json_rpc",
});
if (result.success) {
console.log("Settled:", result.txHash, "Confirmations:", result.confirmations);
}How Verification Works
- Sender creates transfer via wallet RPC → gets
tx_hash+tx_key - Both are encoded in the X-PAYMENT header
- Facilitator calls
check_tx_keyon daemon RPC - Daemon cryptographically proves amount sent to address without revealing sender
Security
- Fail-closed: If daemon RPC is unreachable, payment is rejected
- Replay protection: In-memory Map with 1hr TTL (use Redis/DB for multi-instance)
- CAIP-2:
monero:mainnet - No wallet needed on server: Only daemon RPC access required
Author
Erudite Intelligence LLC
License
MIT
