← Back to Challenger Blog
Guide #02 Wallet Engineering 8 min read · 10k – 1M+ Users

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.

Key Rule for Wallet Teams

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.

← Swipe diagram to inspect →
EDGE · 10K–1M+ USER DEVICES WEB / EXTENSION / ELECTRON ~219 KB gz (488 KB raw) WASM WASM: account_info, ledger, tx, submit. --wallet-ws: +lines, objects, fee. Optional: auto-uses ws://127.0.0.1:6006 IOS / ANDROID NATIVE APP xrpl-light-ffi (Swift & Kotlin UniFFI) Verifies 80% UNL quorum + 16-way SHAMap Merkle proofs on device CPU. Zero private keys leave Secure Enclave YOUR WALLET INFRASTRUCTURE (UNTRUSTED BY CLIENT CPU) STATELESS PROOF RELAYS xrpl-light-relay (multi-region) Fan-out VAL\0 + headers + raw SHAMap proof bytes. Horizontally scalable, 0 state DEDICATED XRPL HUBS challenger / rippled fleet Serves TMGetLedger proofs directly from local NuDB. Zero public hub rate limits EXISTING FULL-NODE / INDEXER CLUSTER (CONVENIENCE PATH) Clio / rippled / Challenger Full Nodes behind WS Load Balancer • account_tx (tx history) • book_offers / amm_info / path_find • account_nfts (gallery) • accounts push notifications Tagged _challenger_verified: false so UI distinguishes history vs proven state SHAMap Proofs History & DEX
Figure 1. Split-plane wallet architecture: verifiable state proofs run at the edge in every user's app; indexed history/DEX runs on your full-node cluster. Scales horizontally to 1M+ users

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.

JavaScript / TypeScript · Hybrid Verified Wallet Client
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:

TypeScript · Auto-Detect Local Node + Verification Badge
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.

← Swipe diagram to inspect →
WALLET APP (EDGE) ~219 KB gz (488 KB raw) WASM Checks UNL + 80% VAL\0 Rejects forged proofs & fails over automatically. Primary Failover RELAY EU (WSS) xrpl-light-relay (stateless) ~3.5k–10k WSS / 2 vCPU (compact) RELAY US (WSS) xrpl-light-relay (stateless) ~3.5k–10k WSS / 2 vCPU (compact) YOUR PRIVATE HUBS Peer over private VPC / LAN 256-ledger online_delete is plenty for live SHAMap proofs No external hub throttling
Figure 2. Multi-region stateless relays backed by your own VPC hubs — clients verify every byte locally and automatically fail over if any relay lies or drops. Zero trust in your own relay tier

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.

Want to Test Against Your Own Wallet Today?

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.