This guide covers Node.js server-side usage. For mobile (iOS/Android) see the React Native guide, and for browser apps see the Web guide. For concepts shared across all guides, see the Quickstart Overview.
Prerequisites
- Node.js v18 or later — Download here
- A testnet BTC balance for transaction fees (see Quickstart Overview for faucet links)
- Basic familiarity with async/await JavaScript
Step 1: Install the SDK
@utexo/rgb-sdk package is Node.js only and is not browser-compatible. It requires access to the file system and native crypto modules. For browser environments use @utexo/rgb-sdk-web; for iOS and Android use @utexo/rgb-sdk-rn.
Step 2: Generate Wallet Keys
Start by generating a BIP-39 mnemonic. This 12-word seed phrase is the only way to recover your wallet — store it securely before proceeding.Step 3: Initialise the Wallet
Create and initialise aUTEXOWallet instance using your mnemonic. Initialisation connects to the default RGB transport and Bitcoin indexer endpoints for testnet.
initialize() performs the initial sync with the Bitcoin indexer and RGB transport layer. This may take a few seconds on first run.
Step 4: Get a Deposit Address
Get your wallet’s Bitcoin deposit address. You will use this to receive testnet BTC from a faucet — a small BTC balance is required to pay RGB transaction fees.Step 5: Create UTXOs
RGB asset state must be anchored to Bitcoin UTXOs. Before you can receive any RGB asset, your wallet needs dedicated UTXOs created for this purpose.refreshWallet() syncs the wallet’s local state with the Bitcoin chain. Always call it after any on-chain operation before querying balances or generating invoices.
Step 6: Get the USDT on Bitcoin Asset ID
Before generating an invoice, you need the asset ID of the USDT on Bitcoin token on testnet. This ID uniquely identifies the asset contract in the RGB protocol.Step 7: Generate an RGB Invoice (Receiver Side)
The receiver generates a blinded invoice to share with the sender. The blinded invoice hides the receiver’s UTXO from the sender while still allowing the transfer to be verified client-side.
Invoices expire after
durationSeconds. The sender must complete the transfer before the invoice expires, otherwise a new invoice is required.
Step 8: Send an RGB Asset (Sender Side)
The sender uses the invoice from Step 7 to transfer the asset. The sender must already hold a balance of the RGB asset being transferred.send() call constructs the RGB state transition, attaches it to a Bitcoin transaction, and broadcasts it. The RGB transport layer (rpcs://) is used to communicate the state transition to the receiver.
The amount and assetId in the send() call must exactly match those in the invoice. Mismatches will cause the transfer to be rejected by the receiver’s client-side validator.
Step 9: Verify the Transfer
After both wallets have calledrefreshWallet(), check the balances to confirm the transfer completed successfully.
100 for the USDT asset. If the transfer is still pending confirmation, call refreshWallet() again after the next Bitcoin block. RGB transfers require Bitcoin confirmation to finalise. On testnet, a new block typically arrives every 1–10 minutes.
Step 10: Create and Pay a Lightning Invoice
With an open Lightning channel, you can send and receive payments usingcreateLightningInvoice and payLightningInvoice.
Opening a channel requires a funded node connected to a peer. Refer to the RGB Lightning Node section for channel management details.
asset.assetId to the USDT asset ID and asset.amount to the RGB amount on the invoice.
Step 11: On-Chain Receive and Send
The sameUTEXOWallet instance handles on-chain Bitcoin addresses and RGB on-chain transfers.
getAddress() returns a standard Bitcoin address for on-chain BTC deposits. blindReceive() returns an RGB blinded invoice for asset transfers. Both are available on every UTEXOWallet instance without additional setup.Troubleshooting
If you encounter an issue not listed here, join the Utexo Discord for community support.
Next Steps
- SDK Reference — Full method reference for
UTEXOWallet, including Lightning channel management and backup - Architecture — Understand how Bitcoin, Lightning, and RGB fit together
- Glossary — Definitions for RGB, PSBT, blinded invoice, UTXO, and other key terms