Skip to main content

Features

Chromia FT4 (Flexible Token 4) is a token standard that facilitates complex account and asset management on Chromia. By leveraging auth descriptors, auth flags, and different sets of configurable rules, FT4 offers a highly flexible and secure environment for managing tokens. Below is a detailed explanation of the key features and components of Chromia FT4.

Account management

FT4 is designed with robust account management features, allowing users to efficiently handle their accounts. Each account is uniquely identified by an ID:

entity account {
key id: byte_array;
index type: text;
}

Accounts can be managed by multiple users, each with different levels of access. The account_auth_descriptor entity defines access metadata for an account, detailing who can control an account and what they can do:

entity account_auth_descriptor {
id: byte_array;
key account, id;
index id;
auth_type;
args: byte_array;
rules: byte_array;
mutable ctr: integer;
created: timestamp;
}

Auth descriptors and access control

FT4 supports the use of multiple key pairs for account access, providing flexibility in how accounts are managed. Auth descriptors specify who can access an account and what they are allowed to do. To prevent performance issues from storing too much data on the chain, there's a limit on the number of auth descriptors per account. By default, this limit is set to 10, but you can adjust it like this:

blockchains:
my_rell_dapp:
module: main
moduleArgs:
lib.ft4.core.accounts:
auth_descriptor:
max_number_per_account: 4

The maximum value for this limit is 200.

Types of auth descriptors

  1. Single-signature auth descriptor: Involves a single signer, identified by a public key (for native postchain signatures) or an EVM account address (for EVM signatures).
  2. Multi-signature auth descriptor: Involves multiple signers, identified by public keys or EVM account addresses.

Auth flags and operation authorization

Auth flags define what actions an auth descriptor can perform on an account. If the authorizing auth descriptor lacks the necessary auth flags, it will be rejected.

Built-in auth flags
  • T (Transfer) flag: Needed for transfer operations.
  • A (Account) flag: Needed for FT4 account operations, like adding or deleting auth descriptors.

Dapps can also create custom auth flags to meet specific authorization needs. While flags can be any string, shorter flags are recommended for better performance.

Expiration rules for auth descriptors

Auth descriptors can have expiration rules that determine their validity. Supported expiration rules include:

  • Block height: Expires after a certain block height.
  • Block time: Expires after a specific block time.
  • Number of authorizations: Expires after being used a set number of times.

Auth descriptors created during account setup cannot have expiration rules to prevent accidental loss of access.

To set the maximum number of rules for an auth descriptor (default is 8), use:

blockchains:
my_rell_dapp:
module: main
moduleArgs:
lib.ft4.core.accounts:
max_auth_descriptor_rules: 4

Asset management

FT4 supports the management of multiple assets. The asset table lists all registered assets:

entity asset {
key id: byte_array;
name;
key symbol: text;
decimals: integer;
issuing_blockchain_rid: byte_array;
icon_url: text;
type: text = ASSET_TYPE_FT4;
mutable total_supply: big_integer;
}

Account balances for assets are tracked in the balance table:

entity balance {
key accounts.account, asset;
mutable amount: big_integer;
}
warning

FT4 assets are not perfectly equivalent to ERC20. You can see the differences here.