Skip to main content

Usage

This page provides detailed documentation for all methods available in the Wallet class and utility functions.

Basic Example

Here's a complete example of using react-native-rgb:

import { 
generateKeys,
Wallet,
BitcoinNetwork,
AssetSchema
} from 'react-native-rgb';

// 1. Generate keys
const keys = await generateKeys(BitcoinNetwork.TESTNET4);

// 2. Create wallet
const wallet = new Wallet(keys, {
network: BitcoinNetwork.TESTNET4,
supportedSchemas: [AssetSchema.NIA, AssetSchema.UDA, AssetSchema.CFA],
});

// 3. Go online
await wallet.goOnline('ssl://electrum.iriswallet.com:50053');

// 4. Create UTXOs
await wallet.createUtxos(false, 5, 1000, 1.0);

// 5. Issue an asset
const asset = await wallet.issueAssetNia('TICKER', 'My Asset', 2, [1000]);

// 6. Get balance
const balance = await wallet.getBtcBalance();
const assetBalance = await wallet.getAssetBalance(asset.assetId);

// 7. Clean up
await wallet.close();

Utility Functions

generateKeys

Generates new keys for a wallet using BIP39 mnemonic. Returns keys including mnemonic, extended public keys, and master fingerprint.

Parameters:

NameTypeDescription
bitcoinNetworkBitcoinNetworkThe Bitcoin network to use (MAINNET, TESTNET, TESTNET4, REGTEST, SIGNET)

Returns: Promise<Keys>

Promise resolving to Keys containing mnemonic, xpub, accountXpubVanilla, accountXpubColored, and masterFingerprint

Example:

const keys = await generateKeys(BitcoinNetwork.TESTNET4);
console.log(keys.mnemonic);

restoreKeys

Restores a wallet from a BIP39 mnemonic phrase. Validates the mnemonic and derives the same keys as generateKeys.

Parameters:

NameTypeDescription
bitcoinNetworkBitcoinNetworkThe Bitcoin network to use (MAINNET, TESTNET, TESTNET4, REGTEST, SIGNET)
mnemonicstringThe BIP39 mnemonic phrase to restore from (12 or 24 words)

Returns: Promise<Keys>

Promise resolving to Keys containing mnemonic, xpub, accountXpubVanilla, accountXpubColored, and masterFingerprint

Example:

const keys = await restoreKeys(
BitcoinNetwork.TESTNET4,
'word1 word2 word3 ... word12'
);

restoreBackup

Restores a wallet from an encrypted backup file. This method decrypts the backup using the provided password and restores all wallet data to the RGB directory. The backup must have been created using the backup method.

Parameters:

NameTypeDescription
pathstringThe file path to the backup file to restore from
passwordstringThe encryption password used to decrypt the backup file

Returns: Promise<void>

Promise that resolves when the backup has been successfully restored

Example:

await restoreBackup('/path/to/backup.rgb', 'secure-password');

decodeInvoice

Decodes an RGB invoice string and returns structured invoice data including asset information, recipient ID, and transport endpoints.

Parameters:

NameTypeDescription
invoicestringThe RGB invoice string to decode

Returns: Promise<InvoiceData>

Promise resolving to InvoiceData containing invoice details, asset schema, assignment, network, and transport endpoints

Example:

const invoiceData = await decodeInvoice(invoiceString);
console.log(invoiceData.assetId);
console.log(invoiceData.recipientId);

Wallet Methods

goOnline

Connects the wallet to an online indexer service for syncing and transaction operations. Must be called before performing operations that require network connectivity.

Parameters:

NameTypeDescription
indexerUrlstringThe URL of the RGB indexer service to connect to (e.g., "ssl://electrum.iriswallet.com:50053")
skipConsistencyCheck (optional)booleanIf true, skips the consistency check with the indexer

Returns: Promise<void>

Promise that resolves when the wallet is successfully connected online

Example:

await wallet.goOnline('ssl://electrum.iriswallet.com:50053');
// Wallet is now online and ready for operations

getBtcBalance

Retrieves the Bitcoin balance for both vanilla and colored wallets. Returns settled, future, and spendable balances for each wallet side.

Parameters:

NameTypeDescription
skipSync (optional)booleanIf true, skips syncing with the indexer before calculating balance

Returns: Promise<BtcBalance>

Promise resolving to BtcBalance containing vanilla and colored wallet balances with settled, future, and spendable amounts

Example:

const balance = await wallet.getBtcBalance();
console.log('Vanilla settled:', balance.vanilla.settled);
console.log('Colored spendable:', balance.colored.spendable);

close

Closes the wallet and releases all associated resources. After calling this method, the wallet instance can no longer be used for operations.

Parameters: None

Returns: Promise<void>

Promise that resolves when the wallet has been successfully closed

Example:

await wallet.close();
// Wallet resources are now freed

backup

Creates an encrypted backup of the wallet data to the specified location. The backup includes all wallet state necessary for full restoration.

Parameters:

NameTypeDescription
backupPathstringThe file path where the backup should be saved
passwordstringThe encryption password for securing the backup file

Returns: Promise<void>

Promise that resolves when the backup has been successfully created

Example:

await wallet.backup('/path/to/backup.rgb', 'secure-password');

backupInfo

Checks whether a backup of the wallet has been created.

Parameters: None

Returns: Promise<boolean>

Promise resolving to true if a backup exists, false otherwise

Example:

const hasBackup = await wallet.backupInfo();
if (!hasBackup) {
await wallet.backup('/path/to/backup.rgb', 'password');
}

blindReceive

Creates a blinded UTXO for receiving RGB assets and generates an invoice. This method blinds an existing UTXO to maintain privacy when receiving assets.

Parameters:

NameTypeDescription
assetIdstring | nullOptional asset ID to embed in the invoice (null accepts any asset)
assignmentAssignmentThe type and amount of assignment to receive (FUNGIBLE, NON_FUNGIBLE, etc.)
durationSecondsnumber | nullOptional invoice expiration duration in seconds (null uses default, 0 means no expiration)
transportEndpointsstring[]Array of transport endpoint URLs (1-3 endpoints) for RGB data exchange (e.g., "rpc://127.0.0.1")
minConfirmationsnumberMinimum number of confirmations required for the transaction to be considered settled

Returns: Promise<ReceiveData>

Promise resolving to ReceiveData containing invoice, recipient ID, expiration, and batch transfer index

Example:

const receiveData = await wallet.blindReceive(
null, // Accept any asset
{ type: 'FUNGIBLE', amount: 1000 },
3600, // 1 hour expiration
['rpc://127.0.0.1'],
1
);
console.log('Invoice:', receiveData.invoice);

witnessReceive

Creates a Bitcoin address for receiving RGB assets via witness transaction and generates an invoice. This method generates a new address from the vanilla wallet.

Parameters:

NameTypeDescription
assetIdstring | nullOptional asset ID to embed in the invoice (null accepts any asset)
assignmentAssignmentThe type and amount of assignment to receive (FUNGIBLE, NON_FUNGIBLE, etc.)
durationSecondsnumber | nullOptional invoice expiration duration in seconds (null uses default, 0 means no expiration)
transportEndpointsstring[]Array of transport endpoint URLs (1-3 endpoints) for RGB data exchange
minConfirmationsnumberMinimum number of confirmations required for the transaction to be considered settled

Returns: Promise<ReceiveData>

Promise resolving to ReceiveData containing invoice, recipient ID, expiration, and batch transfer index

Example:

const receiveData = await wallet.witnessReceive(
assetId,
{ type: 'FUNGIBLE', amount: 500 },
null,
['rpc://127.0.0.1'],
1
);

createUtxos

Creates new UTXOs for RGB operations in a single operation. UTXOs are necessary for receiving and managing RGB asset allocations. This method creates the PSBT, signs it, finalizes it, and broadcasts the transaction.

Parameters:

NameTypeDescription
upTobooleanIf true, creates UTXOs until reaching the target count (ignores num parameter)
numnumber | nullTarget number of UTXOs to create (required if upTo is false)
sizenumber | nullSize in sats for each UTXO to create (required if upTo is false)
feeRatenumberTransaction fee rate in sat/vbyte
skipSync (optional)booleanIf true, skips syncing with the indexer before creating UTXOs

Returns: Promise<number>

Promise resolving to the number of UTXOs successfully created

Example:

const utxosCreated = await wallet.createUtxos(
false, // upTo
5, // num
1000, // size in sats
1.0 // feeRate
);
console.log(`Created ${utxosCreated} UTXOs`);

createUtxosBegin

Begins the process of creating UTXOs by generating an unsigned PSBT. Use this method when you need to sign the transaction externally. Must be followed by createUtxosEnd to complete the operation.

Parameters:

NameTypeDescription
upTobooleanIf true, creates UTXOs until reaching the target count
numnumber | nullTarget number of UTXOs to create (required if upTo is false)
sizenumber | nullSize in sats for each UTXO to create (required if upTo is false)
feeRatenumberTransaction fee rate in sat/vbyte
skipSync (optional)booleanIf true, skips syncing with the indexer before creating UTXOs

Returns: Promise<string>

Promise resolving to an unsigned PSBT string that needs to be signed externally

Example:

const unsignedPsbt = await wallet.createUtxosBegin(
false, 5, 1000, 1.0
);
// Sign PSBT externally, then call createUtxosEnd

createUtxosEnd

Completes the UTXO creation process by finalizing and broadcasting a signed PSBT. This method should be called after createUtxosBegin and external signing.

Parameters:

NameTypeDescription
signedPsbtstringThe PSBT string that has been signed externally
skipSync (optional)booleanIf true, skips syncing with the indexer after processing

Returns: Promise<number>

Promise resolving to the number of UTXOs successfully created

Example:

const utxosCreated = await wallet.createUtxosEnd(signedPsbt);

deleteTransfers

Deletes eligible failed transfers from the wallet database. Only transfers in FAILED status can be deleted.

Parameters:

NameTypeDescription
batchTransferIdxnumber | nullOptional specific batch transfer index to delete (null deletes all failed transfers)
noAssetOnlybooleanIf true, only deletes transfers without associated asset IDs

Returns: Promise<boolean>

Promise resolving to true if any transfers were deleted, false otherwise

Example:

const deleted = await wallet.deleteTransfers(null, true);

failTransfers

Marks eligible transfers as failed in the wallet database. This is useful for cleaning up stuck or expired transfers.

Parameters:

NameTypeDescription
batchTransferIdxnumber | nullOptional specific batch transfer index to mark as failed (null marks all eligible)
noAssetOnlybooleanIf true, only affects transfers without associated asset IDs
skipSync (optional)booleanIf true, skips syncing with the indexer before failing transfers

Returns: Promise<boolean>

Promise resolving to true if any transfers were marked as failed, false otherwise

Example:

const failed = await wallet.failTransfers(null, true);

drainTo

Drains all funds (Bitcoin and RGB assets) from the wallet to a specified address in a single operation. This method creates the PSBT, signs it, finalizes it, and broadcasts the transaction.

Parameters:

NameTypeDescription
addressstringThe Bitcoin address to send all funds to
destroyAssetsbooleanIf true, RGB assets are destroyed; if false, they are transferred if possible
feeRatenumberTransaction fee rate in sat/vbyte

Returns: Promise<string>

Promise resolving to the transaction ID of the drain transaction

Example:

const txid = await wallet.drainTo(
'bc1q...',
false, // Transfer assets if possible
1.0
);

drainToBegin

Begins the drain operation by generating an unsigned PSBT. Use this method when you need to sign the transaction externally. Must be followed by drainToEnd to complete the operation.

Parameters:

NameTypeDescription
addressstringThe Bitcoin address to send all funds to
destroyAssetsbooleanIf true, RGB assets are destroyed; if false, they are transferred if possible
feeRatenumberTransaction fee rate in sat/vbyte

Returns: Promise<string>

Promise resolving to an unsigned PSBT string that needs to be signed externally

Example:

const unsignedPsbt = await wallet.drainToBegin(
'bc1q...',
false,
1.0
);

drainToEnd

Completes the drain operation by finalizing and broadcasting a signed PSBT. This method should be called after drainToBegin and external signing.

Parameters:

NameTypeDescription
signedPsbtstringThe PSBT string that has been signed externally

Returns: Promise<string>

Promise resolving to the transaction ID of the drain transaction

Example:

const txid = await wallet.drainToEnd(signedPsbt);

finalizePsbt

Finalizes a partially signed Bitcoin transaction (PSBT). This completes the transaction by combining all signatures and preparing it for broadcast.

Parameters:

NameTypeDescription
signedPsbtstringThe PSBT string that has been signed (may be partially signed)

Returns: Promise<string>

Promise resolving to the finalized PSBT string ready for broadcast

Example:

const finalizedPsbt = await wallet.finalizePsbt(signedPsbt);

signPsbt

Signs a Bitcoin transaction (PSBT) with the wallet's keys. This method signs all inputs that the wallet can sign and returns the signed PSBT.

Parameters:

NameTypeDescription
unsignedPsbtstringThe unsigned PSBT string to sign

Returns: Promise<string>

Promise resolving to the signed PSBT string

Example:

const signedPsbt = await wallet.signPsbt(unsignedPsbt);

getAddress

Generates and returns a new Bitcoin address from the vanilla wallet. Each call returns the next address in the derivation sequence.

Parameters: None

Returns: Promise<string>

Promise resolving to a new Bitcoin address string

Example:

const address = await wallet.getAddress();
console.log('New address:', address);

getAssetBalance

Retrieves the balance information for a specific RGB asset. Returns settled, future, and spendable balances for the asset.

Parameters:

NameTypeDescription
assetIdstringThe RGB asset identifier to query balance for

Returns: Promise<Balance>

Promise resolving to Balance containing settled, future, and spendable amounts

Example:

const balance = await wallet.getAssetBalance(assetId);
console.log('Settled:', balance.settled);
console.log('Spendable:', balance.spendable);

getAssetMetadata

Retrieves comprehensive metadata for a specific RGB asset. Includes information such as supply, precision, schema type, token data (for UDA), and more.

Parameters:

NameTypeDescription
assetIdstringThe RGB asset identifier to retrieve metadata for

Returns: Promise<AssetMetadata>

Promise resolving to AssetMetadata containing all asset information

Example:

const metadata = await wallet.getAssetMetadata(assetId);
console.log('Asset name:', metadata.name);
console.log('Ticker:', metadata.ticker);
console.log('Precision:', metadata.precision);

getFeeEstimation

Estimates the fee rate required for a transaction to be confirmed within a target number of blocks.

Parameters:

NameTypeDescription
blocksnumberThe target number of blocks for confirmation

Returns: Promise<number>

Promise resolving to the estimated fee rate in sat/vbyte

Example:

const feeRate = await wallet.getFeeEstimation(6); // 6 blocks
console.log('Fee rate:', feeRate, 'sat/vbyte');

getMediaDir

Returns the file system path to the wallet's media directory. This directory stores media files associated with RGB assets (e.g., images for UDA tokens).

Parameters: None

Returns: Promise<string>

Promise resolving to the absolute path of the media directory

Example:

const mediaDir = await wallet.getMediaDir();
console.log('Media directory:', mediaDir);

getWalletData

Retrieves the wallet configuration and metadata. Returns information such as network, supported schemas, xPubs, and wallet directory.

Parameters: None

Returns: Promise<WalletData>

Promise resolving to WalletData containing all wallet configuration

Example:

const walletData = await wallet.getWalletData();
console.log('Network:', walletData.bitcoinNetwork);
console.log('Supported schemas:', walletData.supportedSchemas);

getWalletDir

Returns the file system path to the wallet's data directory. This directory contains all wallet files including the database and media files.

Parameters: None

Returns: Promise<string>

Promise resolving to the absolute path of the wallet directory

Example:

const walletDir = await wallet.getWalletDir();
console.log('Wallet directory:', walletDir);

inflate

Inflates an Inflatable Fungible Asset (IFA) by minting additional supply in a single operation. This method creates the PSBT, signs it, finalizes it, and broadcasts the transaction.

Parameters:

NameTypeDescription
assetIdstringThe IFA asset identifier to inflate
inflationAmountsnumber[]Array of amounts to mint (each amount is allocated to a separate UTXO)
feeRatenumberTransaction fee rate in sat/vbyte
minConfirmationsnumberMinimum number of confirmations required for the transaction to be considered settled

Returns: Promise<OperationResult>

Promise resolving to OperationResult containing the transaction ID and batch transfer index

Example:

const result = await wallet.inflate(
assetId,
[1000, 2000], // Inflation amounts
1.0, // feeRate
1 // minConfirmations
);
console.log('Transaction ID:', result.txid);

inflateBegin

Begins the inflation process by generating an unsigned PSBT. Use this method when you need to sign the transaction externally. Must be followed by inflateEnd to complete the operation.

Parameters:

NameTypeDescription
assetIdstringThe IFA asset identifier to inflate
inflationAmountsnumber[]Array of amounts to mint (each amount is allocated to a separate UTXO)
feeRatenumberTransaction fee rate in sat/vbyte
minConfirmationsnumberMinimum number of confirmations required for the transaction to be considered settled

Returns: Promise<string>

Promise resolving to an unsigned PSBT string that needs to be signed externally

Example:

const unsignedPsbt = await wallet.inflateBegin(
assetId,
[1000, 2000],
1.0,
1
);

inflateEnd

Completes the inflation process by finalizing and broadcasting a signed PSBT. This method should be called after inflateBegin and external signing.

Parameters:

NameTypeDescription
signedPsbtstringThe PSBT string that has been signed externally

Returns: Promise<OperationResult>

Promise resolving to OperationResult containing the transaction ID and batch transfer index

Example:

const result = await wallet.inflateEnd(signedPsbt);

issueAssetCfa

Issues a new Collectible Fungible Asset (CFA) with the specified parameters. CFA assets are fungible tokens that can have associated media files. Each amount in the amounts array will be allocated to a separate UTXO.

Parameters:

NameTypeDescription
namestringThe name of the asset
detailsstring | nullOptional detailed description of the asset
precisionnumberThe decimal precision (divisibility) of the asset (0-18)
amountsnumber[]Array of initial amounts to issue (each allocated to a separate UTXO)
filePathstring | nullOptional path to a media file to associate with the asset

Returns: Promise<AssetCfa>

Promise resolving to AssetCfa containing the asset ID and details

Example:

const asset = await wallet.issueAssetCfa(
'My Collectible Token',
'A detailed description',
2, // precision
[1000, 2000], // amounts
'/path/to/image.png' // Optional media file
);
console.log('Asset ID:', asset.assetId);

issueAssetIfa

Issues a new Inflatable Fungible Asset (IFA) with the specified parameters. IFA assets are fungible tokens that support inflation and replace rights.

Parameters:

NameTypeDescription
tickerstringThe ticker symbol of the asset (e.g., "BTC", "USD")
namestringThe name of the asset
precisionnumberThe decimal precision (divisibility) of the asset (0-18)
amountsnumber[]Array of initial amounts to issue (each allocated to a separate UTXO)
inflationAmountsnumber[]Array of inflation amounts to issue initially (each allocated to a separate UTXO)
replaceRightsNumnumberNumber of replace rights to create (can be 0)
rejectListUrlstring | nullOptional URL to a reject list for the asset

Returns: Promise<AssetIfa>

Promise resolving to AssetIfa containing the asset ID and details

Example:

const asset = await wallet.issueAssetIfa(
'TOKEN',
'My Inflatable Token',
2,
[1000],
[500], // Initial inflation amounts
0, // No replace rights
null // No reject list
);

issueAssetNia

Issues a new Non-Inflatable Asset (NIA) with the specified parameters. NIA assets are simple fungible tokens that cannot be inflated after issuance. Each amount in the amounts array will be allocated to a separate UTXO.

Parameters:

NameTypeDescription
tickerstringThe ticker symbol of the asset (e.g., "BTC", "USD")
namestringThe name of the asset
precisionnumberThe decimal precision (divisibility) of the asset (0-18)
amountsnumber[]Array of initial amounts to issue (each allocated to a separate UTXO)

Returns: Promise<AssetNia>

Promise resolving to AssetNia containing the asset ID and details

Example:

const asset = await wallet.issueAssetNia(
'TICKER',
'My Asset',
2, // precision
[1000, 2000] // amounts
);
console.log('Asset ID:', asset.assetId);
console.log('Balance:', asset.balance);

issueAssetUda

Issues a new Unique Digital Asset (UDA) with the specified parameters. UDA assets are non-fungible tokens that represent unique digital items. Each UDA can have a primary media file and multiple attachment files.

Parameters:

NameTypeDescription
tickerstringThe ticker symbol of the asset
namestringThe name of the asset
detailsstring | nullOptional detailed description of the asset
precisionnumberThe decimal precision (divisibility) of the asset (typically 0 for NFTs)
mediaFilePathstring | nullOptional path to the primary media file for the asset
attachmentsFilePathsstring[]Array of paths to additional attachment files (max 20)

Returns: Promise<AssetUda>

Promise resolving to AssetUda containing the asset ID and details

Example:

const asset = await wallet.issueAssetUda(
'NFT',
'My Unique NFT',
'A unique digital collectible',
0, // precision (typically 0 for NFTs)
'/path/to/image.png', // Primary media
['/path/to/attachment1.pdf'] // Attachments
);

listAssets

Lists all RGB assets known to the wallet, optionally filtered by schema type. Returns assets grouped by schema (NIA, UDA, CFA, IFA).

Parameters:

NameTypeDescription
filterAssetSchemasAssetSchema[]Array of asset schemas to filter by (empty array returns all schemas)

Returns: Promise<Assets>

Promise resolving to Assets object containing arrays of assets grouped by schema

Example:

// List all assets
const allAssets = await wallet.listAssets([]);

// List only NIA assets
const niaAssets = await wallet.listAssets([AssetSchema.NIA]);

console.log('NIA assets:', allAssets.nia);
console.log('UDA assets:', allAssets.uda);

listTransactions

Lists all Bitcoin transactions known to the wallet. Includes transactions created for RGB operations (sends, UTXO creation, drains) as well as regular Bitcoin transactions.

Parameters:

NameTypeDescription
skipSync (optional)booleanIf true, skips syncing with the indexer before listing transactions

Returns: Promise<Transaction[]>

Promise resolving to an array of Transaction objects

Example:

const transactions = await wallet.listTransactions();
transactions.forEach(tx => {
console.log(`${tx.transactionType}: ${tx.txid}`);
console.log(`Received: ${tx.received}, Sent: ${tx.sent}`);
});

listTransfers

Lists all RGB transfers for a specific asset or all assets. Returns user-driven transfers including incoming, outgoing, issuance, and inflation transfers.

Parameters:

NameTypeDescription
assetIdstring | nullOptional asset ID to filter transfers for a specific asset (null returns all transfers)

Returns: Promise<Transfer[]>

Promise resolving to an array of Transfer objects

Example:

// List all transfers
const allTransfers = await wallet.listTransfers(null);

// List transfers for specific asset
const assetTransfers = await wallet.listTransfers(assetId);

allTransfers.forEach(transfer => {
console.log(`Transfer ${transfer.idx}: ${transfer.kind} - ${transfer.status}`);
});

listUnspents

Lists all unspent transaction outputs (UTXOs) in the wallet. Each UTXO includes its Bitcoin balance and any RGB asset allocations.

Parameters:

NameTypeDescription
settledOnlybooleanIf true, only includes settled RGB allocations (default: false includes all)
skipSync (optional)booleanIf true, skips syncing with the indexer before listing unspents

Returns: Promise<Unspent[]>

Promise resolving to an array of Unspent objects

Example:

const unspents = await wallet.listUnspents(false);
unspents.forEach(unspent => {
console.log(`UTXO: ${unspent.utxo.outpoint.txid}:${unspent.utxo.outpoint.vout}`);
console.log(`BTC: ${unspent.utxo.btcAmount} sats`);
console.log(`RGB allocations: ${unspent.rgbAllocations.length}`);
});

refresh

Refreshes RGB transfers by checking for new consignments and updating transfer statuses. This method queries the transport endpoints to fetch new transfer data and processes any pending incoming or outgoing transfers.

Parameters:

NameTypeDescription
assetIdstring | nullOptional asset ID to refresh transfers for a specific asset (null refreshes all)
filterRefreshFilter[]Array of RefreshFilter values to control which transfers are refreshed
skipSync (optional)booleanIf true, skips syncing with the indexer before refreshing

Returns: Promise<Record<string, RefreshedTransfer>>

Promise resolving to a record mapping transfer IDs to RefreshedTransfer objects

Example:

const refreshed = await wallet.refresh(
null, // Refresh all assets
[
{ status: 'WAITING_COUNTERPARTY', incoming: true },
{ status: 'WAITING_CONFIRMATIONS', incoming: false }
]
);
Object.entries(refreshed).forEach(([id, transfer]) => {
console.log(`Transfer ${id}: ${transfer.updatedStatus}`);
});

send

Sends RGB assets to recipients in a single operation. This method creates the PSBT, signs it, finalizes it, and broadcasts the transaction. The recipientMap maps asset IDs to arrays of recipients.

Parameters:

NameTypeDescription
recipientMapRecord<string, Recipient[]>Map of asset IDs to arrays of recipients for that asset
donationbooleanIf true, assets that cannot be fully sent are donated (destroyed) rather than creating change
feeRatenumberTransaction fee rate in sat/vbyte
minConfirmationsnumberMinimum number of confirmations required for the transaction to be considered settled
skipSync (optional)booleanIf true, skips syncing with the indexer before sending

Returns: Promise<OperationResult>

Promise resolving to OperationResult containing the transaction ID and batch transfer index

Example:

const result = await wallet.send(
{
[assetId]: [
{
recipientId: 'recipient-id-123',
assignment: { type: 'FUNGIBLE', amount: 1000 },
transportEndpoints: ['rpc://127.0.0.1']
}
]
},
false, // donation
1.0, // feeRate
1 // minConfirmations
);
console.log('Transaction ID:', result.txid);

sendBegin

Begins the send operation by generating an unsigned PSBT. Use this method when you need to sign the transaction externally. Must be followed by sendEnd to complete the operation.

Parameters:

NameTypeDescription
recipientMapRecord<string, Recipient[]>Map of asset IDs to arrays of recipients for that asset
donationbooleanIf true, assets that cannot be fully sent are donated rather than creating change
feeRatenumberTransaction fee rate in sat/vbyte
minConfirmationsnumberMinimum number of confirmations required for the transaction to be considered settled

Returns: Promise<string>

Promise resolving to an unsigned PSBT string that needs to be signed externally

Example:

const unsignedPsbt = await wallet.sendBegin(
{ [assetId]: [recipient] },
false,
1.0,
1
);

sendEnd

Completes the send operation by finalizing and broadcasting a signed PSBT. This method should be called after sendBegin and external signing.

Parameters:

NameTypeDescription
signedPsbtstringThe PSBT string that has been signed externally
skipSync (optional)booleanIf true, skips syncing with the indexer after processing

Returns: Promise<OperationResult>

Promise resolving to OperationResult containing the transaction ID and batch transfer index

Example:

const result = await wallet.sendEnd(signedPsbt);
console.log('Transaction ID:', result.txid);

sendBtc

Sends Bitcoin to a specified address in a single operation. This method creates the PSBT, signs it, finalizes it, and broadcasts the transaction.

Parameters:

NameTypeDescription
addressstringThe Bitcoin address to send to
amountnumberThe amount to send in satoshis
feeRatenumberTransaction fee rate in sat/vbyte
skipSync (optional)booleanIf true, skips syncing with the indexer before sending

Returns: Promise<string>

Promise resolving to the transaction ID of the Bitcoin transaction

Example:

const txid = await wallet.sendBtc(
'bc1q...',
100000, // 0.001 BTC in sats
1.0 // feeRate
);
console.log('Transaction ID:', txid);

sendBtcBegin

Begins the Bitcoin send operation by generating an unsigned PSBT. Use this method when you need to sign the transaction externally. Must be followed by sendBtcEnd to complete the operation.

Parameters:

NameTypeDescription
addressstringThe Bitcoin address to send to
amountnumberThe amount to send in satoshis
feeRatenumberTransaction fee rate in sat/vbyte
skipSync (optional)booleanIf true, skips syncing with the indexer before creating the PSBT

Returns: Promise<string>

Promise resolving to an unsigned PSBT string that needs to be signed externally

Example:

const unsignedPsbt = await wallet.sendBtcBegin(
'bc1q...',
100000,
1.0
);

sendBtcEnd

Completes the Bitcoin send operation by finalizing and broadcasting a signed PSBT. This method should be called after sendBtcBegin and external signing.

Parameters:

NameTypeDescription
signedPsbtstringThe PSBT string that has been signed externally
skipSync (optional)booleanIf true, skips syncing with the indexer after processing

Returns: Promise<string>

Promise resolving to the transaction ID of the Bitcoin transaction

Example:

const txid = await wallet.sendBtcEnd(signedPsbt);

sync

Synchronizes the wallet with the connected indexer. Updates the wallet's view of the blockchain state, including UTXO status, transaction confirmations, and RGB transfer states. This method requires the wallet to be online (goOnline must be called first).

Parameters: None

Returns: Promise<void>

Promise that resolves when synchronization is complete

Example:

await wallet.sync();
// Wallet state is now synchronized with the indexer