text stringlengths 0 1.08k |
|---|
## PFA (Permissioned Fungible Asset) |
This schema defines a permissioned, non-inflatable fungible asset, in which the issuer needs to explicitly authrize every transfer; e.g. it may be used to represent company shares, for which there are legal constraints on the potential owners. It involves the following data: |
* AssetSpec: groups basic asset information, namely: |
* Ticker: short identifier of the asset, to be displayed on wallets and exchanges. Note that there is no guarantee of uniqueness |
* Name: extended name of the asset |
* Details: optional string describing the asset in more detail |
* Precision: Number of decimal places of the standard representation of the asset |
* Contract Terms: contains a string describing the contract and an optional media attachment |
* Issued Supply: total amount of tokens created at issuance. Since the asset is not inflatable, it also serves as an upper bound on the circulating supply |
* Pubkey: public key identifying the entity that needs to sign every transfer |
The following operations are supported for the asset: |
* Transfer: send some amount of assets to a number of destinations (optionally including change); it supports multiple inputs in case multiple allocations should be merged in order to build up the desired output amount and it must have a metadata containing the issuer's signature, which is checked by the receiving wall... |
*** |
In the next subsection, we will provide an example of an actual Schema used for the issuance of a **Non Inflatable Asset.** |
# Schema example: Non-Inflatable Assets |
In this section, we will look more closely at an actual example of an RGB Contract Schema written in Rust and contained in the nia.rs (from the rgb-schemas repository at github.com/rgb-protocol/rgb-schemas) file from the [RGB Schemata Repository](https://docs.rgb.info/annexes/rgb-library-map#rgb-schemata). The Reposito... |
We can observe that a Schema can be divided into several general sections: |
* A *header* which contains: |
* An optional Root `SchemaId` which indicates a limited form of inheritance from some master schema. |
* A reserved `Feature` field which provides room for additional future extensions of contract schema. |
* A first section in which all the **State Types** and related variables (both pertaining to [Global](https://docs.rgb.info/rgb-state-and-operations/components-of-a-contract-operation#global-state) and [Assignments](https://docs.rgb.info/rgb-state-and-operations/components-of-a-contract-operation#assignments)) are decl... |
* A second section where all the possible [Contract Operations](https://docs.rgb.info/annexes/glossary#contract-operation) referencing the previously declared State Types are encoded. |
* A field containing the declaration of the **Strict Type System** being used in the whole schema. |
* A last section containing the **validation scripts** for all the operations. |
After this layout indication, we provide below the actual Rust Code of the schema. Each code section is provided with a numbered reference to an explanation paragraph reported below. |
{% code fullWidth="true" %} |
```rust |
fn nia_schema() -> Schema { |
// definitions of libraries and variables |
Schema { |
ffv: zero!(), // --+ |
name: tn!("NonInflatableAsset"), // | (1) |
meta_types: none!(), // --+ |
global_types: tiny_bmap! { // --+ |
GS_NOMINAL => GlobalDetails { // | |
global_state_schema: GlobalStateSchema::once(types.get("RGBContract.AssetSpec")), // | |
name: fname!("spec"), // | |
}, // | |
GS_TERMS => GlobalDetails { // | |
global_state_schema: GlobalStateSchema::once(types.get("RGBContract.ContractTerms")), // | (2) |
name: fname!("terms"), // | |
}, // | |
GS_ISSUED_SUPPLY => GlobalDetails { // | |
global_state_schema: GlobalStateSchema::once(types.get("RGBContract.Amount")), // | |
name: fname!("issuedSupply"), // | |
}, // | |
}, // --+ |
owned_types: tiny_bmap! { // --+ |
OS_ASSET => AssignmentDetails { // | |
owned_state_schema: OwnedStateSchema::Fungible(FungibleType::Unsigned64Bit), // | |
name: fname!("assetOwner"), // | (3) |
default_transition: TS_TRANSFER, // | |
} // | |
}, // --+ |
genesis: GenesisSchema { // --+ -------> Contract declaration start here |
metadata: none!(), // | |
globals: tiny_bmap! { // | |
GS_NOMINAL => Occurrences::Once, // | |
GS_TERMS => Occurrences::Once, // | |
GS_ISSUED_SUPPLY => Occurrences::Once, // | |
}, // | (4) |
assignments: tiny_bmap! { // | |
OS_ASSET => Occurrences::OnceOrMore, // | |
}, // | |
validator: Some(LibSite::with(FN_NIA_GENESIS_OFFSET, alu_id)), // | |
}, // --+ |
transitions: tiny_bmap! { |
TS_TRANSFER => TransitionDetails { // --+ |
transition_schema: TransitionSchema { // | |
metadata: none!(), // | |
globals: none!(), // | |
inputs: tiny_bmap! { // | |
OS_ASSET => Occurrences::OnceOrMore // | |
}, // | (5) |
assignments: tiny_bmap! { // | |
OS_ASSET => Occurrences::OnceOrMore // | |
}, // | |
validator: Some(LibSite::with(FN_NIA_TRANSFER_OFFSET, alu_id)// | |
}, // | |
name: fname!("transfer"), // | |
} // --+ |
}, |
default_assignment: Some(OS_ASSET), // --+ (6) |
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.