Skip to main content

JavaScript and TypeScript

RGB v0.11 line (rgb-cmd 0.11.1)

Every JavaScript option on this page is for Line B. Line A (v0.12) has no JavaScript SDK: use the rgb CLI or the Rust crate rgb-runtime. See Two RGB lines.

@rgbjs/* packages don't exist

Earlier versions of this site documented @rgbjs/core, @rgbjs/wallet, @rgbjs/react, @rgbjs/cli, @rgbjs/testing and similar packages. None of them was ever published, and the @rgbjs scope isn't registered on npm, so anyone could claim those names. Don't install them. The API that page described (RgbWallet, Rgb20Contract, React hooks, a window.rgb provider) never existed.

Options​

Versions are from npm view and GitHub on 2026-10-19.

PackageRuns inMaintainerStatus
rgb-lib 0.3.0-beta.7 (2026-07-18)Node.js, as a native addonRGB-Tools (rgb-lib-nodejs)Official bindings of rgb-lib. Beta.
@utexo/rgb-lib-wasm 1.0.0-beta.3Browsers (WASM)Utexo (rgb-lib-wasm)Third party. Its README says it "has not been audited". NIA and IFA only, Esplora over HTTP, IndexedDB storage.
@utexo/rgb-sdk-core, -web, -rn (1.0.0 betas)Node.js, browsers, React NativeUtexoThird-party, higher-level TypeScript wrappers over rgb-lib. Beta. The older @utexo/rgb-sdk repo is archived.
RGB Lightning Node REST APIAny language over HTTPRGB-ToolsA daemon with an OpenAPI spec (/issueassetnia, /rgbinvoice, /sendrgb, /refreshtransfers, /backup and more). Its README calls it "early alpha", for regtest and testnet.

The unscoped npm package rgbjs is a 0.0.1 placeholder. The rgbjs project (rgbjs.com) is in development and has no published SDK yet.

Third-party packages hold your keys and RGB data. Read their code and pin exact versions before you trust them with funds.

rgb-lib for Node.js​

Install it with npm install rgb-lib. npm picks the right platform package (@rgb-tools/rgb-lib-<os>-<arch>). This sketch follows the project's example.js. Numbers are passed as strings, and the indexer and proxy are the local regtest services from Testing.

const rgblib = require("rgb-lib");

const net = rgblib.BitcoinNetwork.Regtest;
const keys = rgblib.generateKeys(net, rgblib.WitnessVersion.Taproot);
const wallet = new rgblib.Wallet(
new rgblib.WalletData({
dataDir: "./data",
bitcoinNetwork: net,
databaseType: rgblib.DatabaseType.Sqlite,
maxAllocationsPerUtxo: "1",
supportedSchemas: [rgblib.AssetSchema.Nia],
}),
new rgblib.SinglesigKeys({
accountXpubVanilla: keys.accountXpubVanilla,
accountXpubColored: keys.accountXpubColored,
vanillaKeychain: null,
masterFingerprint: keys.masterFingerprint,
mnemonic: keys.mnemonic,
}),
);
try {
// Fund wallet.getAddress() first.
const online = wallet.goOnline({
indexerUrl: "tcp://localhost:50001",
skipConsistencyCheck: false,
vanillaSyncLookback: 20,
});
wallet.createUtxos(online, false, "5", null, "1", false);
const asset = wallet.issueAssetNIA("DEMO", "Demo asset", "0", ["1000"]);
console.log(wallet.getAssetBalance(asset.assetId));
wallet.refresh(online, null, [], false);
wallet.backup("./wallet.backup", "backup password");
} finally {
wallet.drop(); // the Node bindings leak memory unless you free the wallet
}

Sending and receiving use blindReceive / witnessReceive on the recipient, then send and refresh on both sides. The Rust guide shows the same flow with the full argument lists, and Wallet integration explains the rules around it.

Old names and their real equivalents​

Name on the old page (invented)Real rgb-lib call
new RgbWallet(config) + initialize()new rgblib.Wallet(new rgblib.WalletData({...}), new rgblib.SinglesigKeys({...})), then wallet.goOnline({...})
key setuprgblib.generateKeys(network, witnessVersion) / rgblib.restoreKeys(network, mnemonic, witnessVersion)
Rgb20Contract.create(...)wallet.issueAssetNIA(ticker, name, precision, amounts) (also issueAssetCFA, issueAssetUDA)
createInvoice(...)wallet.blindReceive(...) or wallet.witnessReceive(...); parse an invoice with rgblib.invoiceData(str)
transfer(...)wallet.send(...), or sendBegin + signPsbt + sendEnd
acceptTransfer(consignment)wallet.refresh(online, assetId, filter, skipSync): consignments move through the RGB proxy server
getBalance / listAssets / listUtxosgetAssetBalance(assetId) / listAssets(schemas) / listUnspents(...)
exportStash / importStashwallet.backup(path, password) / rgblib.restoreBackup(path, password, dir)
releaseWasmMemory()wallet.drop()

There is no RGB WalletConnect method, injected browser provider or React binding in any of these packages.