The RGB code, compiled for JavaScript

RGB is now two incompatible protocols: v0.11, maintained by the RGB Protocol Association, and v0.12, maintained by RGB-WG. rgbjs doesn't reimplement either. It compiles each line's own Rust crates to WebAssembly and puts one small JavaScript API on top, so browsers, PWAs and Node get the same rules the reference code checks.

๐Ÿ”€

Both lines

rgbjs/v011 and rgbjs/v012 wrap each line's crates. rgbjs tells you which line an invoice or file belongs to and sends it to the right one.

๐Ÿ”’

No keys, offline

rgbjs never holds a key. A payment comes back as an unsigned PSBT for your own signer, with the transfer for the payee. It works offline; its only network call is an opt-in lookup of witness transactions.

๐Ÿงช

Not for real funds

Nothing is released yet. Don't use rgbjs with real assets until a release says it's ready.

API

// Not on npm yet: use the GitHub repo
import { parseInvoice, validateConsignment } from 'rgbjs'

const invoice = parseInvoice(text)
invoice.line        // 'v0.11' or 'v0.12'
invoice.contractId  // contract ID, if the invoice names one
invoice.amount      // requested amount, if any
invoice.beneficiary // where the asset goes

const result = validateConsignment(bytes)  // a .rgb file
result.valid        // valid if its witness transactions confirm

Status

Works now

Both lines: parse invoices and contract IDs, tell the lines apart, validate contracts and transfers offline, issue contracts and invoices on test networks, and see what a transfer pays you. v0.12: pay invoices, committing with OP_RETURN or tapret. Create or check your own. The conformance page runs the upstream test vectors and payments mined on a test network in your browser. Bunting, a wallet in a browser tab, uses rgbjs on the Bitcoin BLAKE2b testnet4.

Next

A first npm release, then payments for v0.11. Version 0.0.1 until then.

Later

NFT transfers (RGB21), which the pinned v0.12 code can't build yet, and whatever the wallets built on rgbjs need.

Docs

Both RGB lines are documented at rgb-docs.github.io.