Operating Zero-Trust XRPL Verification Inside a Production Wallet
If you build or operate a mainstream XRPL wallet (Xaman, Crossmark, GemWallet, Joey, Bifrost, or an exchange custody app), you should never funnel 100,000 users through one centralized light client. Instead, push cryptographic verification to the edge — inside every user's app — backed by your own stateless proof relays and full nodes.
Centralizing challenger-light is an anti-pattern at scale: a single light-client daemon connects to 2 upstream hubs and pulls SHAMap proofs on demand. Putting thousands of users behind one box defeats zero-trust and will trip public hub rate limits. The right architecture scales horizontally to millions of users by embedding the ~219 KB gzipped (488 KB raw) WASM verifier inside the wallet client itself.
Production Architecture: Edge Verification + Stateless Proof Fleet
In a large-wallet deployment, your existing full-node cluster keeps doing what full nodes are great at — serving historical transaction indexes (account_tx), DEX orderbooks (book_offers), NFT galleries, and real-time account push notifications — while every high-integrity state read (balances, reserves, sequences, fees, trustlines, objects, and transaction inclusion) is cryptographically proven on the user's own CPU.
1Drop-In Integration With Your Existing xrpl.js Client
You do not need to rewrite your wallet's RPC layer. wrapXrplClient() wraps your existing xrpl.Client in a transparent ES Proxy: verifiable commands route through Challenger Light and are cryptographically checked locally, while convenience commands fall through to your existing cluster.
import { Client } from "xrpl";
// Production: pin the npm package (or self-host with an SRI hash) rather than an unpinned remote URL:
import { wrapXrplClient } from "challenger-light-xrpl";
// 1. Your existing production RPC cluster (for account_tx, book_offers, push)
const historyCluster = new Client("wss://rpc.yourwallet.com");
// 2. Wrap with Challenger Light:
// - Local `challenger-light --wallet-ws`: verifies account_info, account_lines,
// account_objects, fee, server_state, ledger, ledger_entry, tx, submit, and ledgerClosed.
// - Browser WASM (`lightClient: new ChallengerLightClient({ relays: [...] })`): verifies
// account_info, ledger, ledger_entry, tx, submit, and server_info locally, and
// automatically routes account_lines/account_objects/fee to historyCluster (with fee clamping).
const client = wrapXrplClient(historyCluster, {
walletWs: "ws://127.0.0.1:6006",
maxFeeDrops: 2_000_000n, // Hard 2 XRP ceiling clamps fees on both verified & fallback paths
});
await client.connect();
// Verified locally on both browser WASM and --wallet-ws (fails closed if proof is forged):
const xrpBalance = await client.getXrpBalance(userAddress);
// Verified locally on --wallet-ws; falls back to historyCluster when running browser WASM:
const trustlines = await client.request({ command: "account_lines", account: userAddress, limit: 100 });
// Convenience history still works transparently via your cluster:
const history = await client.request({ command: "account_tx", account: userAddress, limit: 20 });
console.log(history.result._challenger_verified); // false (unverified convenience read)
2Offer a 1-Click "Local Node" + "SHAMap Verified" Badge
Use createEmbeddedClient() to automatically detect if a power user has challenger-light --wallet-ws running locally (600 ms loopback probe), and fall back seamlessly to your multi-relay WASM verifier if not:
import { createEmbeddedClient } from "challenger-light-xrpl";
const client = await createEmbeddedClient({
autoLocal: true, // Probes ws://127.0.0.1:6006 for 600ms first
probeTimeoutMs: 600,
fallbackClient: historyCluster,
});
const acct = await client.request({ command: "account_info", account: userAddress });
// Render a cryptographic verification badge in your wallet UI:
const badge = acct.result._challenger_verified
? `SHAMap Verified (${client.transportKind()})`
: "Unverified RPC";
3Routing Matrix: Verified Plane vs. Convenience Plane
Every RPC call in a modern XRPL wallet falls cleanly into one of two trust planes:
| RPC Command | Trust Plane | Why / Behavior in challenger-light-xrpl |
|---|---|---|
account_info / ledger_entry |
Verified Locally (WASM + Daemon) | 16-way SHAMap proof against 80% UNL quorum root on both browser WASM and challenger-light --wallet-ws |
account_lines / account_objects |
Verified Locally (--wallet-ws) | OwnerDirectory walk + fail-closed proof on challenger-light --wallet-ws / local RPC; browser WASM falls back to fallbackClient (or throws in strict: true) |
fee / server_state |
Verified Locally (--wallet-ws) | SHAMap-verified FeeSettings on --wallet-ws / local RPC; browser WASM falls back to fallbackClient. Both paths enforce maxFeeDrops clamping |
server_info / ledger |
Verified Locally (WASM + Daemon) | 80% UNL validator quorum header on both browser WASM and --wallet-ws (with maxFeeDrops clamping on server_info) |
ledger_closed / subscribe |
Verified Locally (--wallet-ws) | streams: ["ledger"] runs on --wallet-ws with auto-reconnect; accounts/transactions/books subscriptions route to fallbackClient |
submit & tx |
Verified Locally (WASM + Daemon) | Direct P2P / multi-relay broadcast + SHAMap transaction tree inclusion proof on both browser WASM and --wallet-ws |
account_tx / book_offers / account_nfts |
Convenience Cluster | Routed to fallbackClient (tagged _challenger_verified: false; blocked in strict: true) |
4Run Your Own Stateless Proof Relays (Zero Third-Party Limits)
For browser and mobile users who are not running a local daemon, run 2+ geo-distributed xrpl-light-relay instances peered directly with your own Challenger or rippled hubs. Because relays are 100% untrusted by the client, a compromised relay can never forge a balance or fee — and multi-relay failover eliminates single-region censorship or downtime. In compact mode, plan for roughly 3.5k–10k concurrent WSS connections per 2 vCPU depending on quorum batching and active proof-query rate.
Production Hardening Checklist for Wallet Operators
1. Protect Against Fee-Griefing
Always set maxFeeDrops (e.g. 2_000_000n) on wrapXrplClient(). Even if a fallback node returns an inflated fee or load_factor, the SDK clamps it locally before signing.
2. Handle OutcomeUnknown
If submitAndWait() cannot confirm inclusion before LastLedgerSequence and cannot prove your Sequence is still unused, it throws code: "OutcomeUnknown". Never auto-retry with a new Sequence without re-checking verified account_info.
3. Fail Closed on High-Value Flows
For institutional transfers, key rotations, or signer-list edits, instantiate a strict: true client so no unverified RPC can ever slip into the signing pipeline.
4. Native Mobile via UniFFI
For iOS and Android wallets, compile crates/xrpl-light-ffi to generate native Swift and Kotlin bindings — zero WebView overhead and full offline UNL/SHAMap verification.
In production, pin the challenger-light-xrpl npm/workspace package (or self-host with Subresource Integrity hashes) rather than importing an unpinned remote URL. For quick browser prototyping, a hosted ESM mirror is available at https://light.lukejudges.com/embed/challenger-xrpl.js, and you can read Post #01 for end-user local node setup.