This project builds Node.js packages for the rgb-lib Rust library, which is included as a git submodule. The bindings are created using the rgb-lib C++ bindings, which are located inside the rgb-lib submodule, and Swig.
Bindings are platform-specific and are published into dedicated packages (under the @rgb-tools namespace). The main package is a thin layer that depends on the correct platform-specific package for the platform where it's being installed.
- Node.js 22 or 23 (the bindings require Node.js 21+ and the native addon doesn't build against the V8 of Node.js 24+)
- Python 3
- development tools (e.g. make, g++)
Install the package with npm:
npm install rgb-libImport the package with:
const rgblib = require("rgb-lib");Then call its exported functions. As an example:
let keys = rgblib.generateKeys(
rgblib.BitcoinNetwork.Regtest,
rgblib.WitnessVersion.Taproot,
);
console.log(keys);All integers are BigInt, both when passed to the functions (including inside
objects, e.g. the assignments) and when returned by them. The exceptions are
the fee estimation, which is a floating-point number, and the bytes of byte
arrays (embedded media data and proofs of reserves), which are numbers.
JSON.stringify doesn't support BigInt without a replacer (see the example).
⚠️ Warning: memory will be leaked if not taken care of manuallyCheck the example to see how you can manually avoid memory leaks