JavaScript for both RGB lines, v0.11 and v0.12. Early development.

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 belongs to and sends it to the right one.

๐Ÿ”’

Read-only first

The first release holds no keys and opens no network connections: it parses and writes invoices, formats contract IDs and checks consignments offline.

๐Ÿงช

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, and validate contracts and transfers offline. Check your own. The conformance page runs the upstream test vectors in your browser.

Next

Transfer consignment vectors for both lines, then a first npm release. Version 0.0.1 until then.

Later

Wallet features such as paying and accepting transfers, once the read-only layer is solid.

Docs

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