Skip to main content
The @utexo/rgb-sdk-web package is the browser SDK for the Utexo stack. All operations run locally via an RGB Lightning Node (RLN) compiled to WebAssembly — no RGB server, no Node.js, no native binaries. UTEXOWallet mirrors the React Native SDK surface, so app code ports across web ↔ mobile with minimal change.
This SDK is designed for browser environments only. It is not compatible with Node.js (use @utexo/wdk-rgb-lightning) or React Native (use @utexo/rgb-sdk-rn).This is a beta release — APIs may change between releases.

What You Can Do

  • Run a full Lightning node in the browser via the RLN WASM SDK
  • Open Lightning channels and send/receive BTC or RGB asset payments
  • LSP integration: receive RGB via Lightning, send RGB to on-chain recipients, Lightning Address
  • Async payments (APay): hash pool + Lightning Address via utexo-lsp
  • Issue, transfer, and manage RGB assets (NIA, IFA, CFA)
  • Manage UTXOs and BTC on-chain sends — atomic (sendBtc) or 3-step begin → sign → end for external signers
  • Encrypted file backup (raw bytes, browser-download friendly) and VSS cloud backup
  • HODL invoices: create, claim, cancel

Requirements

  • Modern browser with WebAssembly and top-level await support: Chrome, Firefox, Safari, Edge
  • ESM-only bundler: Vite, Webpack 5, Rollup, or esbuild — CommonJS is not supported
  • At create time: an Esplora indexer, an RGB proxy (transport) endpoint, and — for Lightning — a WebSocket LN gateway. Known networks get defaults — see Default endpoints

Installation

Bundler setup (Vite)

The WASM module initialises asynchronously; exclude the package from Vite’s dependency pre-bundling and enable WASM + top-level-await support:

Initialisation

The primary class is UTEXOWallet. The constructor is sync and cheap (params are only stored); init() does all local WASM work and returns the wallet LOCKED; unlock() brings it online.
init() and unlock() are idempotent and retryable after a thrown failure; unlock() throws unless init() ran first. Wallet/network methods throw until unlock() resolves. UTEXOWallet.create(params) is a one-call convenience for constructor + init() + unlock(). initialize() is an alias for that sequence.
The current constructor accepts one parameter object. The older new UTEXOWallet(mnemonic, options) form and a standalone create(mnemonic, options) factory do not match the current implementation.

UTEXOWalletCreateParams

Lifecycle

The initunlock gap is the explicit VSS-restore window:
  1. new UTEXOWallet(params) + await wallet.init() — loads WASM, derives keys, creates the wallet from local storage, creates the Lightning node handle (when proxyUrl resolves), and configures VSS. The wallet is LOCKED: wallet/network ops throw; key reads (getXpub, getNodePubkey) and VSS restore APIs work.
  2. Optional: await wallet.restoreFromVss({ takeoverFence? }) — explicit cloud restore on a new device. Restore is never automatic.
  3. await wallet.unlock() — validates the password, configures LDK/channel VSS replication, and auto-connects to the indexer non-fatally.
  4. isOnline() / goOnline(indexerUrl) — check the connection; retry when offline. goOnline is idempotent.
  5. dispose() — release the WASM wallet/node handles. Check with isDisposed().

Networks

Utexo Network Faucet — To get test BTC and RGB assets on the Utexo network, use the Telegram bot @Utexo_RLN_bot.Limited to 2 requests per 24 hours per user.

Default Endpoints

Used automatically when the corresponding create param is omitted (DEFAULT_RLN_URLS): On networks without a proxyUrl default, pass one explicitly to enable the Lightning node; without it the wallet is on-chain RGB only.

Vanilla vs Colored Addresses

The SDK operates two separate derivation paths, consistent with the React Native SDK:
  • Vanilla — standard Bitcoin derivation path for BTC receives, fee payments, and on-chain withdrawals. getAddress() returns a vanilla bech32 receive address.
  • Colored — RGB-specific derivation path. Used internally when creating UTXOs for RGB asset allocations.
getBtcBalance() returns separate balances for each path, each with settled, future, and spendable fields. getXpub() returns { xpubVan, xpubCol }.

Wallet Methods

Key Generation

  • generateKeys(network?) — Generate new wallet keys. Returns mnemonic, xpubs, and master fingerprint.
  • restoreKeys(network, mnemonic) / deriveKeysFromMnemonic / deriveKeysFromSeed — Derive keys from existing material.
  • initRlnWasm() — Explicit WASM init (singleton — create() calls it automatically).

Wallet State

Call syncWallet() after funding or UTXO creation to update chain state. Call refreshWallet() after onchainSend() to update RGB transfer status on both sender and receiver sides.

UTXO Management

Before issuing or receiving RGB assets, colored UTXOs must be created. Call createUtxos() after funding the vanilla address:

RGB Asset Methods

Issuing Assets

Receiving Assets

RGB receive flows support two invoice styles:
  • Blinded invoice — most common. The receiver creates a blinded endpoint; the sender pays directly.
  • Witness invoice — the receiver binds the transfer to witness data. The sender must provide witnessData (at minimum amountSat) in onchainSend().
onchainReceive() is the single entry point. Witness invoices are the default; pass witness: false for a blinded invoice. blindReceive() and witnessReceive() remain available as the underlying primitives.

Sending Assets

Lightning Methods

Lightning requires a resolved proxyUrl (set or defaulted, e.g. utexo) and usable peer/channel state.
openChannel both opens and funds the channel, then returns once the funding tx is submitted — poll listChannels() until isUsable.
For a BTC-only invoice, omit the asset field and pass amountSats.

LSP & Async Payments (APay)

See the LSP guide and async payments guide in the package repo for composed UtexoLsp flows.

Backup and Restore

Backups are recommended after every significant state change: UTXO creation, asset issuance, and transfers.

File Backup

Creates an encrypted backup as raw bytes. Store or download the bytes — there is no file path in the browser.

VSS Backup

VSS keeps an encrypted remote copy of the wallet (RGB assets, stock, BDK state) and the node’s LDK/channel state. Identity is derived from the mnemonic at init(); the server defaults to DEFAULT_VSS_SERVER_URL. Backup is automatic during normal operation.
Restore is explicit — one call in the init → unlock gap, never automatic:
Only restore when the old device is actually gone. Two live writers on one channel store risk fund loss. If the old device might still be running, pass { takeoverFence: false }.

Security

The browser SDK is fully non-custodial. Private keys and mnemonics are never transmitted to remote servers. WASM runs in the browser’s sandboxed environment. VSS values are encrypted client-side. For hardware wallet or external signer support, use the manual begin/end send flow:
The same begin/end pattern applies to UTXO creation (createUtxosBegin / createUtxosEnd) and BTC sends (sendBtcBegin / sendBtcEnd).
Store mnemonics securely and never log or transmit them. In browser environments, use the Web Crypto API or a secure vault rather than localStorage.

Demo App

A full working demo is available at rgb-sdk-web-sandbox. It covers the UTEXOWallet lifecycle, Lightning, LSP/APay, and file + VSS backup.

Further Reading