WDK logoWDK documentation

RGB wallet API reference

Public API reference for the released @utexo/wdk-wallet-rgb 2.0.3 community module.

This page covers the public declarations and runtime methods in @utexo/wdk-wallet-rgb@2.0.3.

Community modules are developed and maintained independently by third-party contributors.

Tether and the WDK Team do not endorse or assume responsibility for their code, security, or maintenance. Use your own judgment and proceed at your own risk.

Package

FieldValue
Package@utexo/wdk-wallet-rgb@2.0.3
RepositoryUTEXO-Protocol/wdk-wallet-rgb
Module formatESM
Entriesindex.js; conditional Bare entry bare.js
Declarationstypes/index.d.ts

Exports

ExportDescription
defaultWalletManagerRgb
WalletAccountRgbFull account class
WalletAccountReadOnlyRgbQuery-only account class
TypesRgbWalletConfig, RgbTransaction, TransferOptions, RgbTransactionReceipt, RgbTransferReceipt, and WDK fee/key/result aliases

RgbWalletConfig

FieldRuntime requirementDescription
networkRequired'mainnet', 'testnet', or 'regtest'.
dataDirOptional at constructionLocal RGB state path. Treat it as operationally required and persistent.
indexerUrlOptionalElectrs-compatible indexer endpoint.
transportEndpointOptionalRGB consignment transport endpoint.
keysInternalGenerated by WalletManagerRgb; applications normally do not set it.
transferMaxFeeNot effective through the manager pathDeclared on the config/account, but WalletManagerRgb.getAccount() does not forward it to the account in v2.0.3. Enforce a fee limit in application code after quoting.

The generated RgbWalletConfig TypeScript alias exposes only network and keys, although the released runtime and JSDoc accept dataDir, indexerUrl, transportEndpoint, and transferMaxFee. JavaScript can pass the operational fields; TypeScript consumers may need a local, release-scoped augmentation until the package declarations are corrected.

WalletManagerRgb

MemberReturnsBehavior
constructor(seed, config)WalletManagerRgbAccepts a BIP-39 mnemonic string or seed bytes. Runtime requires config.network.
getAccount(index = 0)Promise<WalletAccountRgb>Creates or returns the only account. Any nonzero index throws.
restoreAccountFromBackup(config)Promise<WalletAccountRgb>Restores the backup into config.dataDir, creates the account, and caches it at index 0.
getAccountByPath(path)Promise<never>Always throws; arbitrary paths are unsupported.
getFeeRates()Promise<{normal: bigint, fast: bigint}>Reads mempool.space recommended fees without selecting the wallet network.
dispose()voidClears manager-owned derived-key fields and disposes cached accounts.

WalletAccountRgb

Static factories

MemberReturnsNotes
WalletAccountRgb.at(seed, config)Promise<WalletAccountRgb>Low-level factory used by WalletManagerRgb.getAccount(). It requires config.network and generated config.keys, and accepts dataDir, indexerUrl, and transportEndpoint. Applications should normally use manager.getAccount(0) so the manager derives the keys and caches the account.
WalletAccountRgb.fromBackup(seed, config)Promise<WalletAccountRgb>Low-level restore factory used by WalletManagerRgb.restoreAccountFromBackup(). It requires config.network, generated config.keys, backupFilePath, password, and dataDir; it restores before opening the account. Prefer the manager method so keys are derived and the restored account is cached at index 0.

Both declarations make config optional, but the v2.0.3 runtime throws when these required fields are absent.

Identity and WDK methods

MemberReturnsNotes
index0The only supported account index.
pathstringm/86'/0'/0' on mainnet; m/86'/1'/0' otherwise.
coloredPathstringm/86'/827166'/0' on mainnet; m/86'/827167'/0' otherwise.
keyPairRgbKeyPairIncludes WDK key bytes plus RGB xpubs and fingerprint. Treat every returned key field as sensitive.
getAddress()stringReturns the current Bitcoin address synchronously.
getBalance()Promise<bigint>Settled Bitcoin balance in satoshis.
getTokenBalance(assetId)Promise<bigint>Settled RGB amount in the asset's base unit.
sign(message)Promise<string>Signs through the underlying RGB wallet.
verify(message, signature)Promise<boolean>Full-account verification.
sendTransaction(tx)Promise<{hash, fee}>Sends Bitcoin with sendBtcBegin → signPsbt → sendBtcEnd.
quoteSendTransaction(tx)Promise<{fee}>Builds and signs a PSBT to estimate the fee.
transfer(options)Promise<{hash, fee}>Sends an RGB asset to an rgb: invoice.
quoteTransfer(options)Promise<{fee}>Builds and signs an RGB PSBT to estimate the fee.
getTransfers(options?)RgbTransfer[]Filters and paginates; returns [] for both no results and any underlying error.
toReadOnlyAccount()Promise<WalletAccountReadOnlyRgb> in the declarationsThe v2.0.3 runtime returns synchronously, but await works with both behaviors and satisfies the published type.
dispose()voidZeroes the wrapper's derived private-key bytes and disposes its RGB wallet.

RGB, UTXO, and state methods

MethodReturnsNotes
getRgbWallet()RGB SDK WalletManagerAdvanced escape hatch; its API and lifecycle are maintained by @utexo/rgb-sdk.
listAssets()ListAssets[]Current asset inventory.
issueAssetNia({ticker, name, amounts, precision})IssueAssetNIAIssues a Non-Inflatable Asset. Other issuance schemas are not declared by this release.
receiveAsset({assetId?, amount, witness})InvoiceReceiveDataCreates a witness invoice when witness is true, otherwise a blind invoice.
sendBegin(options)stringCreates a base64 PSBT for an RGB send.
signPsbt(psbt)Promise<string>Signs a base64 PSBT.
sendEnd({signedPsbt})SendResultFinalizes and broadcasts the RGB send.
createUtxos(options)Promise<number>Combined create/sign/finalize flow.
createUtxosBegin(options)stringCreates a UTXO-creation PSBT.
createUtxosEnd({signedPsbt})numberFinalizes UTXO creation.
listUnspents()Unspent[]Current RGB wallet UTXOs.
listTransactions()RgbTransactionReceipt[]Bitcoin transaction records.
listTransfers(assetId?)RgbTransfer[]Native transfer list with optional asset filter.
failTransfers(request)booleanForwards transfer-failure handling to the RGB SDK. The v2.0.3 declaration and JSDoc disagree on the parameter name/type; inspect the matching SDK before calling it.
createBackup({password, backupPath})Backup responseCreates an encrypted backup file.
restoreFromBackup({password, backupFilePath, dataDir})Restore responseLow-level account restore. Prefer the manager restore flow before opening the destination.
refreshWallet()voidRefreshes RGB transfer state.
registerWallet()Promise<{address, btcBalance}>Registers the wallet and returns its address and Bitcoin balance.
syncWallet()voidSynchronizes with the Bitcoin chain.

Version 2.0.3 has a declaration/runtime mismatch for sendEnd(): the published declaration requires signed_psbt, while the runtime reads signedPsbt. Pass the runtime-correct camel-case field and use a narrow type assertion until the upstream declaration is corrected:

const request = { signedPsbt } as unknown as Parameters<typeof account.sendEnd>[0]
const result = account.sendEnd(request)

WalletAccountReadOnlyRgb

The read-only class is constructed from an address and configuration. It inherits balance methods and exposes:

MethodReturnsBehavior
getBalance()Promise<bigint>Settled Bitcoin balance.
getTokenBalance(assetId)Promise<bigint>Settled RGB balance.
getTransactionReceipt(hash)Promise<RgbTransactionReceipt | null>Bitcoin receipt or null.
getTransferReceipt(hash)Promise<RgbTransferReceipt | null>RGB transfer receipt or null.
quoteSendTransaction()Rejected promiseRead-only accounts cannot construct or sign a quote PSBT.
quoteTransfer()Rejected promiseRead-only accounts cannot construct or sign a quote PSBT.

The v2.0.3 read-only class does not implement verify(). Use a live full account or a separately validated public-key verification path.

Input shapes

Bitcoin transaction

FieldRequiredMeaning
toYesBitcoin address.
valueYesSatoshis as number or bigint.
feeRateNosat/vbyte; send defaults to 1, while quote obtains an estimate.

RGB transfer

FieldRequiredMeaning
recipientYesSingle-use RGB invoice beginning with rgb:.
tokenYesRGB asset ID.
amountYesAsset base units as number or bigint.
feeRateNoBitcoin fee rate in sat/vbyte.
minConfirmationsNoMinimum confirmations.
witnessDataNoOptional {amountSat, blinding} witness data.

Release-specific cautions

  • getTransfers() suppresses native errors and returns []; use direct state checks when an empty result is consequential.
  • sendTransaction() wraps Bitcoin-send failures with the text RGB transfer failed, so the prefix does not identify the failed operation.
  • Quote methods construct and sign PSBTs. Treat them as wallet operations, not pure arithmetic.
  • getFeeRates() reads main mempool.space recommendations without choosing testnet or regtest.
  • transferMaxFee is dropped by the normal manager-to-account construction path. Quote and enforce your own limit before sending.
  • Preserve and back up dataDir; do not assume the mnemonic alone reconstructs RGB state.

Guides

On this page