03 / 06Advanced
Asset basics
This lesson covers the core ideas behind FT4 assets and how they work on Chromia.
What are FT4 assets?
An FT4 asset is a digital token that stands for anything of value on the Chromia blockchain. You create these tokens with the FT4 library, which gives you a standard way to define and manage them.
Key components of FT4 assets
Account management
- Pool accounts that manage assets
- User accounts that hold assets
- Multiple account types, each with its own permissions
Asset registration
- You must register each asset on the blockchain
- Each asset gets a unique identifier
- Properties such as name, symbol, and number of decimal places describe an asset
Asset operations
- Minting: creates new units of an asset
- Burning: destroys existing units
- Transferring: moves units from one account to another
- Locking: blocks an asset from moving for a period of time
Account types of the dapp
The project relies on two main kinds of account:
Pool account
- Handles the initial distribution of the asset
- Controlled by the dapp
User accounts
- Users create these themselves
- Hold assets and send them to other accounts
Permissions on an FT4 account depend on what the account is for. To keep things simple, this project uses only two roles: user and admin.
Asset registration
Next, you set up a basic asset configuration and register the asset.
Put the following code in src/main/module.rell:
import lib.ft4.assets.{ asset, Unsafe };import lib.ft4.core.accounts.strategies.open;// Asset propertiesval account_type = "PoolAccount";val asset_name = "TestAsset";val asset_symbol = "TAT";val asset_decimals = 6;val asset_icon_url = "https://url-to-asset-icon";val asset_amount_to_mint = 1000000000L;val asset_amount_to_faucet = 100000L;val asset_amount_to_burn = 100L;object dapp_meta { asset = Unsafe.register_asset( asset_name, asset_symbol, asset_decimals, chain_context.blockchain_rid, asset_icon_url );}This code sets the asset's configuration and registers the asset when the blockchain initializes.
The next lesson adds operations for minting, burning, and transferring the asset.