@opaquecash/react wraps the SDK client in idiomatic React hooks. It has a single
peer dependency (react >= 18) and works with any wallet stack (wagmi, RainbowKit,
Solana wallet-adapter, starknet.js, or your own).
Install
Provide the client
Build the client withOpaqueClient.fromWallet when the user connects, keep it in
state, and hand it to OpaqueProvider. Pass null while the session is connecting;
the hooks stay idle until a client arrives.
Rebuild the client (and call
setClient) when the connected wallets change. Pass the
cached walletSignature to fromWallet so the rebuild does not prompt for a new
signature; the hooks re-run automatically because the context value changed.useOpaqueClient() / useOpaqueClientOrNull()
useScan(options?)
Scan the unified cross-chain inbox. Scans once on mount (and whenever the client or
options change); set pollInterval to keep it fresh.
Returns
{ outputs, loading, error, refresh }.
useStealthBalance(outputs)
Resolve the native balance of each owned output (typically the outputs from
useScan). Refetches when the output set or client changes.
{ balances, totals, loading, error }. totals is a partial per-chain record
({ ethereum?, solana?, starknet? }) — a key is present only for chains that returned a
balance — with amounts in base units (wei / lamports / fri).
Writes
The hooks cover the read side. For sends, sweeps, registration, and PSR writes, call the client directly from event handlers:sendStealthPayment and registerMetaAddress accept "ethereum" and "solana"
only. On Starknet the client returns unsigned calls for your Starknet wallet to
broadcast — client.buildStarknetStealthSend(...) and client.buildStarknetSweep(...).
See Starknet for the full flow.