RGB on the BLAKE2b testnet4
Everything on this page uses Line A, through rgbjs, which compiles the v0.12 crates to WebAssembly. See Two RGB lines.
The BLAKE2b testnet4 is a test network. Its coins have no value, and rgbjs and Bunting are early, independent projects. Don't use them for real funds.
The Bitcoin BLAKE2b testnet4 (txbt4) is a fork of testnet4 by Bitcoin Knots. It shares testnet4's history up to block 150,307, then switches to 164-byte version-2 block headers with BLAKE2b proof of work from block 150,308. Its explorer is mempool.guide, which serves the usual Esplora API at https://mempool.guide/testnet4/api. Addresses use the testnet prefix tb.
RGB runs on it unchanged, and three RGB payments have been mined there so far. This page explains why it works, the one thing that differs in practice, and how to try it.
Why RGB works unchanged​
RGB never looks at block headers or proof of work. Client-side validation needs three things from the chain: the witness transactions, their transaction IDs, and whether they are mined. On txbt4:
- Transactions are Bitcoin's. The fork's rules change headers, proof of work, the header's committed height and transaction count, and a block-weight cap. They don't touch the transaction format.
- Transaction IDs are Bitcoin's. A txid is still the double SHA-256 of the transaction without witnesses, so an RGB anchor to a txbt4 transaction verifies exactly as on testnet4.
- Signatures are Bitcoin's. Ordinary BIP 341 taproot key-path signatures are valid. The chain also offers an opt-in "unified" signature hash, but nothing requires it.
So a v0.12 contract, invoice or consignment is the same bytes on txbt4 as on testnet4. A file can't say which of the two chains its witnesses are on: a witness that one explorer doesn't know may be on the other.
OP_RETURN can be refused; tapret isn't​
The first RGB payment on txbt4 used an opret commitment, the only kind rgb-wallet 0.12.0-rc.3 makes. mempool.guide's node refused to relay it (sendrawtransaction error -26, with no reason given). A Bitcoin Knots node with default settings (datacarrier on, up to 83 bytes) accepted the same transaction (testmempoolaccept: allowed), and it was mined after being relayed from there. The signature and the transaction were valid, so the likely cause is the explorer node's data-carrier policy: Knots lets an operator turn datacarrier off or lower datacarriersize below the 34 bytes of an opret script. The node's actual settings weren't checked.
A tapret commitment has no OP_RETURN output: it hides inside the change output's taproot key, so data-carrier limits never apply. The second payment used tapret, and mempool.guide's node accepted it directly.
If a node you depend on limits OP_RETURN data, use tapret. It is also more private (the payment looks like any taproot spend) and one output smaller. The cost is that the wallet must keep the tapret tweak to spend that change later; see Spending a tapret output.
rgb-wallet 0.12.0-rc.3 can't make tapret payments: its payment path always adds an OP_RETURN host. rgbjs can, with payInvoice({ …, commit: 'tapret' }), which marks the change output as the tapret host instead. The pinned rgb-wallet accepts the result.
Try it in a browser: Bunting​
Bunting is a small RGB wallet for txbt4 that runs in a browser tab (source, AGPL). It uses rgbjs for all the RGB work and signs and broadcasts the transactions itself:
- Make a wallet. One random seed, kept in the tab, gives a BIP 86 taproot account (
m/86'/1'/0') and the secrets for RGB seals and invoices. - Get test coins. Send txbt4 to the wallet's address.
- Issue. An RGB20 token (ticker, fixed supply) or an RGB25 asset (no ticker, with terms) on one of your coins. Issuing costs nothing on chain: the contract names the coin that holds the supply.
- Make an invoice. Bunting puts the payment on a coin with no other asset on it, and keeps the invoice's secret so it can recognize the payment later. The invoice can carry an expiry (the v0.12
?expiry=field, written in UTC with aZ: upstreamsonic-callreq0.12.0 writes a+00:00offset that its own parser rejects). An expired invoice stops holding its coin, and Bunting won't pay one. - Pay an invoice. rgbjs builds the witness transaction as an unsigned PSBT with a tapret commitment. Bunting signs it (BIP 341, checked against the BIP's own test vectors), broadcasts it to the explorer and to Nostr relays, and gives you the transfer to hand to the payee, as a file or a link.
- Take a transfer in. The payee opens the link or loads the file. Bunting validates it with rgbjs and finds the state paid to its invoices.
When the payer opened a pay link, the transfer also goes to the payee over Nostr. Each Bunting wallet has a Nostr key derived from its seed, and its pay links name it (&to=<pubkey>). The payer's wallet encrypts the transfer to that key with NIP-44 version 2 and publishes it as a kind 1059 event signed by a throwaway key, so the event shows neither who paid nor what. The payee's wallet keeps a subscription open while its tab is open, and checks again when it refreshes; it takes each transfer in as it arrives.
Links carry their data in the query string: ?pay=<invoice> opens Bunting with the invoice ready to pay, and ?transfer=<gzip, base64url> takes a transfer in (about 5 KB for a payment with two earlier payments in its history). The same works after #, which keeps the data out of the request to the web server. A transfer shows its payment history, so share its link only with the payee.
Each coin carries at most one asset, and Bunting won't sign a payment that would also spend a coin carrying another asset, which would lose it. Back up both the seed and the asset backup (contract files, invoice secrets and tapret records): the seed alone brings back the keys but not the assets.
To check a txbt4 transfer without a wallet, load it in the rgbjs Check page and look its witnesses up on "BLAKE2b testnet4, txbt4 (mempool.guide)".
Checking confirmations in the tab​
An RGB transfer is only final once its witness transactions are mined, so "is it mined?" matters. Bunting, and the rgbjs Check page when you pick the BLAKE2b testnet4, don't take the explorer's word for it. For each witness they check, in the browser:
- The merkle proof. The explorer's proof leads from the transaction ID to the merkle root in the block's header.
- The header's proof of work. The 164-byte v2 header hashes to the block hash under the chain's BLAKE2b construction, using the hasher from bitcoin-desktop/schema (
codec/pow/knots-header-v2.js, loaded pinned to a commit). The hash must meet the target in the header'sbits, within testnet4's limit; the header's committed height must match; and its time may be at most two hours ahead. - The difficulty. Each header's
bitsmust follow the testnet4 rules the fork keeps: the minimum difficulty only when the block comes more than 20 minutes after the previous one, otherwise the period's difficulty, and at each 2016-block boundary the BIP 94 retarget. (The check reproduces txbt4's real retarget at block 153,216.) - The links. Every header from that block up links to the one before it, with the same checks. Only headers walked this way count as confirmations.
- The signed tip. The tip the chain's publisher signs on Nostr (NIP-333 kind 33333 events, as blaketestnode follows) has its signature checked, and the walk from each witness's block must reach that tip's exact hash. Only then does the page call the witness part of the signed chain.
The last check carries the most weight on txbt4. Every recent block there is mined under the 20-minute minimum-difficulty exception, so the difficulty rules alone don't stop an explorer from fabricating a branch of cheap blocks. They do limit how far ahead of real time such a branch can run: each block needs a 20-minute gap, and no block may be more than two hours ahead. A branch that doesn't lead to the publisher's signed tip is reported as such. The explorer is still trusted for the current tip height and for what is in the mempool; a full node validating in the tab, as Reef runs, removes it altogether.
Mined payments​
These three transfers are in the rgbjs test vectors (test/vectors/v012/mined-*.transfer.rgb) and the conformance suite. The pinned rgb-wallet accepts all three (accept -u, exit 0).
| File | Payment | Commitment | Witness | Block |
|---|---|---|---|---|
mined-opret.transfer.rgb | 250 FLAG, to the same wallet | opret | c14ab82f… | 153,561 |
mined-tapret.transfer.rgb | 500 FLAG, to the same wallet | tapret | a564889f… | 153,562 |
mined-to-bob.transfer.rgb | 100 FLAG, from one wallet to another | tapret | 3e0bafc9… | 153,567 |
FLAG is an RGB20 token with the standard fungible issuer. Each later file carries the earlier payments as history, since each one spent the previous change.
Further reading​
- Tapret and Opret: the two commitment schemes.
- JavaScript and TypeScript: rgbjs and the other JavaScript options.
- Consignments: what a transfer file holds.