Documentation Index
Fetch the complete documentation index at: https://utexo-e7ed9bd0-feat-faucet-bot.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
What You Will Build
This guide walks you through the full Utexo SDK integration flow: installing the SDK, generating and initializing a wallet, funding it with testnet BTC, creating UTXOs to anchor RGB state, generating an RGB invoice and completing your first USDT transfer on Bitcoin. By the end of this guide you will have:- A working
UTEXOWalletinstance connected to testnet - A funded wallet with UTXOs ready to receive RGB assets
- Successfully sent and verified an RGB USDT transfer
Estimated time: 15 minutes, not counting testnet faucet confirmation time (usually 1–5 minutes, but can vary).
How RGB Transfers Work
Before writing any code, it helps to understand the flow:- The receiver generates a blinded invoice tied to one of their UTXOs
- The sender calls
.send()with that invoice - the RGB state transition is constructed and broadcast - Both wallets call
.refreshWallet()to sync the latest on-chain state - The receiver’s balance updates to reflect the new asset allocation
New to RGB or UTXOs? See the Glossary for definitions, and Architecture for how Bitcoin, Lightning, and RGB fit together.
Prerequisites
Before you start, make sure you have the following:- Node.js v18 or later — Download here
- A testnet BTC balance for transaction fees. Get testnet BTC from the Utexo Telegram faucet bot @Utexo_RLN_bot — send
/getbtcfollowed by your Bitcoin address. - Basic familiarity with async/await JavaScript
Network Endpoints (Testnet)
The SDK connects to the following endpoints by default on testnet. No configuration is needed to follow this guide.| Service | Endpoint |
|---|---|
| RGB Transport | rpcs://rgb-proxy.utexo.com/json-rpc |
| Bitcoin Indexer | https://esplora-api.utexo.com |
For mainnet endpoint configuration, see the SDK Reference.
Step 1: Install the SDK
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: Initialize the Wallet
Create and initialize aUTEXOWallet instance using your mnemonic. Initialization 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 the Telegram faucet bot — a small BTC balance is required to pay RGB transaction fees./getbtc with this address to @Utexo_RLN_bot (see Prerequisites). Wait for at least 1 confirmation before continuing.
You only need a small amount — a few thousand satoshis is enough to cover fees for this tutorial.
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.| Parameter | Type | Description |
|---|---|---|
num | number | Number of UTXOs to create. 5 is recommended for a new wallet. |
size | number | Size of each UTXO in satoshis. 1000 satoshis per UTXO is the minimum recommended value. |
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 RGB USDT Asset ID
Before generating an invoice, you need the asset ID of the RGB USDT token on testnet. This ID uniquely identifies the asset contract in the RGB protocol.If no assets appear, your wallet may not yet have been assigned any RGB assets. You can also obtain the canonical testnet USDT asset ID from the SDK Reference or by asking in the Utexo Discord.
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.| Parameter | Type | Description |
|---|---|---|
assetId | string | The RGB asset contract ID. See Step 6. |
amount | number | Amount to receive in asset base units. For RGB USDT, 1 unit = 1 USDT. |
minConfirmations | number | Minimum Bitcoin confirmations required before accepting the transfer. |
durationSeconds | number | Invoice validity window in seconds. Invoice is rejected by the receiver after expiry. |
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.The
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.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 finalize. On testnet, a new block typically arrives every 1–10 minutes.
Troubleshooting
| Issue | Likely cause | Fix |
|---|---|---|
initialize() hangs or times out | No network connection to indexer | Check your internet connection and firewall settings |
createUtxos() fails | Insufficient BTC balance | Fund your wallet with more testnet BTC via /getbtc on @Utexo_RLN_bot |
| Invoice rejected | Invoice has expired | Generate a new invoice and retry |
send() fails with validation error | amount or assetId mismatch | Confirm the send parameters exactly match the invoice |
| Balance not updated after send | Wallet not synced | Call refreshWallet() on both sender and receiver wallets |
| Asset ID not found | Asset not yet in wallet | Check listAssets() or obtain the canonical asset ID from the SDK reference |
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 - Architecture — Understand how Bitcoin, Lightning, and RGB fit together
- Glossary — Definitions for RGB, PSBT, blinded invoice, UTXO, and other key terms