Skip to main content

Issuing fungible tokens

Applies to both RGB lines

Both lines can issue a fixed-supply fungible token, but with different tools and incompatible contracts. See Two RGB lines.

Issuing a token means creating a contract genesis: the token's name and supply, and one or more seals (Bitcoin UTXOs) that own the initial supply. Issuing is offline: genesis is not a Bitcoin transaction and nothing is published on chain. The UTXOs you assign the supply to must already exist in your wallet.

  • v0.11: a fixed-supply token is a contract of the NIA (Non-Inflatable Asset) schema. For a supply you can increase later, use IFA (Secondary issuance).
  • v0.12: a fixed-supply token is issued with the RGB20-FNA issuer ("Fungible Non-inflatable Asset").
Try it in the browser first

rgbjs Create issues a test-network contract of either line offline (NIA and the other v0.11 schemas, or RGB20-FNA and RGB25 for v0.12) and gives you the .rgb file to inspect on Check. It's independent and early, and it doesn't hold keys or touch the network. For anything you'll use, issue with the wallet below.

Token parameters​

Fieldv0.11 (NIA, AssetSpec)v0.12 (RGB20-FNA)
Ticker1–8 characters, starting with a letter (rgb-ops stl/specs.rs). rgb-lib also requires upper case.2–8 characters (rgb-interfaces 0.12 names.rs)
Name1–40 printable ASCII charactersGlobal name
DetailsOptional, 1–255 bytesNot in the example issuer
Precision0–18Global precision, by name (for example centiMilli)
TermsContractTerms { text, media }: a text and an optional attachment (media type plus digest)Not in the example issuer
SupplyGlobal issuedSupply, which must equal the sum of the allocations (errno 1, ERRNO_ISSUED_MISMATCH)Global issued

Precision sets the number of decimal places. Amounts in RGB are always whole numbers of the smallest unit: with precision 2, an allocation of 100000 displays as 1,000.00.

ValueNameValueNameValueName
0Indivisible6Micro12Pico
1Deci7DeciMicro13DeciPico
2Centi8CentiMicro14CentiPico
3Milli9Nano15Femto
4DeciMilli10DeciNano16DeciFemto
5CentiMilli11CentiNano17CentiFemto
18Atto

Source: Precision in rgb-invoicing 0.11.1 src/amount.rs. Tickers aren't unique. Anyone can issue a contract with any ticker, so wallets identify assets by contract ID.

Back up after issuing

A seed phrase does not recover RGB assets. The contract and its state live in the wallet's data directory (or in rgb-lib's backup), so back it up as soon as you have issued. Tapret wallets also need their tapret tweaks backed up.

v0.11: NIA​

With the CLI​

rgb-cmd issues from a YAML file that names the schema, its globals and the seal that receives the supply. The full walkthrough, with real output, is step 5 of the Quick Start. In short:

schema: rgb:sch:RWhwUfTMpuP2Zfx1~j4nswCANGeJrYOqDcKelaMV4zU#remote-digital-pegasus

globals:
spec:
ticker: DEMO
name: Demo Asset
details: ~
precision: 2
terms:
text: demo NIA asset
media: ~
issuedSupply: 100000

assignments:
assetOwner:
seal: <txid>:<vout>
amount: 100000
rgb -n regtest -d data0 import rgb-schemas/schemata/NonInflatableAsset.rgb
rgb -n regtest -d data0 -w issuer issue "ssi:issuer" demo.yaml
rgb -n regtest -d data0 -w issuer contracts

rgb issue prints A new contract rgb:… is issued and added to the stash. The contract ID changes on every run, because the genesis seal is blinded with a random value. Templates for each schema are in rgb-sandbox contracts/.

With rgb-lib (Rust)​

rgb-lib is what Line B wallets use. It holds the keys, manages UTXOs and embeds the schemas. This code is for rgb-lib 0.3.0-beta.7, which needs Rust 1.88. It passes cargo check (2026-10-21) but wasn't run, because it needs an indexer. All functions used are in src/keys.rs and src/wallet/singlesig.rs at that tag. A new project needs rgb-lib's Cargo.lock to resolve: see Installation.

[dependencies]
rgb-lib = "=0.3.0-beta.7"
use rgb_lib::keys::{generate_keys, WitnessVersion};
use rgb_lib::wallet::{DatabaseType, OnlineOptions, SinglesigKeys, Wallet, WalletData};
use rgb_lib::{AssetSchema, BitcoinNetwork};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let network = BitcoinNetwork::Regtest;
let keys = generate_keys(network, WitnessVersion::Taproot);
// Store keys.mnemonic safely. It is needed, but not enough, to restore the wallet.

std::fs::create_dir_all("rgb-data")?;
let mut wallet = Wallet::new(
WalletData {
data_dir: "rgb-data".to_string(),
bitcoin_network: network,
database_type: DatabaseType::Sqlite,
max_allocations_per_utxo: 5,
// Must not be empty: an empty list fails with NoSupportedSchemas,
// despite the field's doc comment (src/wallet/core.rs).
supported_schemas: vec![AssetSchema::Nia],
},
SinglesigKeys::from_keys(&keys, None),
)?;

let online = wallet.go_online(OnlineOptions {
indexer_url: "127.0.0.1:50001".to_string(), // your Electrum server
skip_consistency_check: false,
vanilla_sync_lookback: 20,
})?;
println!("fund this address: {}", wallet.get_address()?);

// After funding: create UTXOs to hold RGB allocations (fee rate in sat/vB).
wallet.create_utxos(online, false, None, None, 2, false)?;

// Ticker, name, precision, and one amount per allocation.
let asset = wallet.issue_asset_nia("DEMO".into(), "Demo Asset".into(), 2, vec![100_000])?;
println!("issued {}", asset.asset_id);
Ok(())
}
  • issue_asset_nia is offline. Each entry in amounts becomes a separate allocation on a separate UTXO, which must already exist (create_utxos).
  • rgb-lib puts empty terms in genesis. To set your own terms or details, use the Rust builder below.
  • The RGB Lightning Node exposes the same call as POST /issueassetnia with {"ticker", "name", "precision", "amounts"}.
  • The Kotlin, Swift, Python and Node.js (npm rgb-lib) bindings expose issue_asset_nia too (as issueAssetNIA in Node.js). The Node.js bindings lack the IFA calls (issueAssetIFA, inflate, burn); see JavaScript and TypeScript.

With the Rust contract builder​

To control every field, build genesis with rgb-ops and rgb-schemas 0.11.1:

[dependencies]
rgb-ops = { version = "=0.11.1", features = ["fs"] }
rgb-schemas = "=0.11.1"

Don't add these to a project that also uses rgb-lib 0.3.0-beta.7: rgb-lib pins rgb-ops and rgb-schemas to =0.11.1-rc.11 (its Cargo.toml), so Cargo can't resolve both. This is the core of examples/nia.rs (rgbstd is the library name of the rgb-ops crate, and schemata that of rgb-schemas):

use rgbstd::contract::IssuerWrapper; // for NonInflatableAsset::schema()
use rgbstd::stl::{AssetSpec, ContractTerms, RicardianContract};
use rgbstd::invoice::Precision;
use rgbstd::{Amount, ChainNet};
use schemata::NonInflatableAsset;

let spec = AssetSpec::new("DEMO", "Demo Asset", Precision::Centi);
let terms = ContractTerms { text: RicardianContract::default(), media: None };

let contract = stock
.contract_builder("ssi:anonymous", NonInflatableAsset::schema().schema_id(), ChainNet::BitcoinTestnet4)?
.add_global_state("spec", spec)?
.add_global_state("terms", terms)?
.add_global_state("issuedSupply", Amount::from(100_000u64))?
.add_fungible_state("assetOwner", genesis_seal, 100_000u64)?
.issue_contract()?;

Here stock is a Stock with the NIA kit imported, and genesis_seal is a GenesisSeal built with BlindSeal::with_blinding(txid, vout, blinding). See examples/common/mod.rs for both. issue_contract_raw(timestamp) gives a fixed timestamp, which makes the contract ID reproducible in tests.

Next​