RGB-21: NFT collectibles

LNPBP: 0021
Vertical: Smart contracts
Title: RGB non-fungible assets interface for collectibles (RGB-21)
Authors: Dr Maxim Orlovsky <[email protected]>,
Hunter Trujillo,
Federico Tenga,
Zoe Faltibà,
Carlos Roldan,
Olga Ukolova,
Giacomo Zucco,
Armando Dutra
Comments-URI: <>
Status: Proposal
Type: Standards Track
Created: 2020-09-10
Updated: 2023-05-10
License: CC0-1.0





  • Media as URI (which can be attachments distributed with Storm or usual URLs)
  • Small media ("previews" if given together with large media)
  • Fraction of assets
  • Engravings
  • Reserves
  • Possible decentralized issue


Interface specification is the following Contractum code:
-- Defined by LNPBP-31 standard in `RGBContract.sty` file
import level_decide_percent_6z2gZQEJsnP4xoNUC94vqYEE9V7gKQbeJhb5521xta5u as RGBContract
-- # Defining main data structures
data ItemsCount :: U32
-- each collectible item is unique and must have an id
data TokenIndex :: U32
data OwnedFraction :: U64
-- allocation of a single token or its fraction to some transaction output
data Allocation :: TokenIndex, OwnedFraction
data EngravingData ::
appliedTo TokenIndex,
content EmbeddedMedia
data EmbeddedMedia ::
type RGBContract.MediaType,
data [Byte]
data Attachment ::
type RGBContract.MediaType,
digest: [U8 ^ 32] -- this can be any type of 32-byte hash, like SHA256(d), BLACKE3 etc
data TokenData ::
index TokenIndex,
ticker RGBContract.Ticker?,
name RGBContract.Name?,
details RGBContract.Details?,
-- always-embedded preview media < 64kb
preview EmbeddedMedia?,
-- external media which is the main media for the token
media Attachment?,
attachments { U8 -> ^ ..20 Attachment } -- auxiliary attachments by type (up to 20 attachments)
-- output containing locked bitcoins; how reserves are proved is a matter
-- of a specific schema implementation
reserves RGBContract.ProofOfReserves?
-- each attachment type is a mapping from attachment id
-- (used as `Token.attachments` keys) to a short Ascii string
-- verbally explaining the type of the attachment for the UI
-- (like "sample" etc).
data AttachmentType ::
id U8,
name AttachmentName
data AttachmentName :: [Std.AsciiPrintable ^ 1..20]
interface RGB21
-- Asset specification containing ticker, name, precision etc.
global spec :: RGBContract.DivisibleAssetSpec
-- Contract text and creation date is separated from the spec since it must
-- not be changeable by the issuer.
global terms :: RGBContract.RicardianContract
global created :: RGBContract.Timestamp
-- Data for all issued tokens
global tokens* :: TokenData
global engravings* :: EngravingData
global attachmentTypes* :: AttachmentType
-- Right to do a secondary (post-genesis) issue
public inflationAllowance* :: ItemsCount
-- Right to update asset name
public updateRight?
-- Ownership right over assets
private assetOwner* :: Allocation
genesis -> spec
, terms,
, created,
, tokens*
, assetOwner*
, inflationAllowance*
, updateRight?
, attachmentTypes*
, reserves {RgbTypes.ProofOfReserves ^ 0..0xFFFF}
!! invalidProof
-- this error happens when amount of token > 1
| fractionOverflow
| insufficientReserves
| invalidAttachmentType
op Transfer :: previous assetOwner+,
-> beneficiaries assetOwner+
!! -- options for operation failure:
| fractionOverflow
| nonFractionalToken
op? Engrave :: previous assetOwner+
, engravings
-> beneficiaries assetOwner+
!! -- options for operation failure:
| nonFractionalToken
| nonEngravableToken
op? Issue :: used inflationAllowance
, newTokens tokens*
, newAttachmentTypes attachmentTypes*
, reserves {RgbTypes.ProofOfReserves ^ 0..0xFFFF}
-> future inflationAllowance
, beneficiaries assetOwners+
!! invalidProof
| fractionOverflow
| insufficientReserves
| issueExceedsAllowance
| invalidAttachmentType
op? Rename :: used updateRight
-> future updateRight?
, new spec



Reference implementation



This document is licensed under the Creative Commons CC0 1.0 Universal license.