05 / 15Module 1: Registering accounts and assetsAdvanced
Create user accounts
This course centers on building a marketplace, with token transfers as the core topic, so account creation is kept deliberately simple.
For a full walkthrough of registering accounts with EVM wallets, see the account registration lesson in the News feed dapp course.
Configure FT4 account module
To set up FT4 accounts, add the configuration below to the lib.ft4.core.accounts module.
blockchains: rell_marketplace: module: main moduleArgs: lib.ft4.core.accounts: rate_limit: max_points: 10 recovery_time: 5000 points_at_account_creation: 2compile: rellVersion: 0.14.9database: schema: schema_rell_marketplacetest: modules: - rell_marketplace_testlibs: ft4: registry: https://gitlab.com/chromaway/ft4-lib.git path: rell/src/lib/ft4 tagOrBranch: v1.2.0r rid: x"E96915FD7C9A5DD4E183D86F4A5B4BB5083A7CC1EDEB1465EDFFC926E67C93F6" insecure: false iccf: registry: https://gitlab.com/chromaway/core/directory-chain path: src/lib/iccf tagOrBranch: 1.87.0 rid: x"9C359787B75927733034EA1CEE74EEC8829D2907E4FC94790B5E9ABE4396575D" insecure: falseWith the rate-limit setting points_at_account_creation set to 2, a new account starts with 2 points, so it can perform 2 operations before it has to wait for points to recover. The recovery_time property controls how long points take to recover and defaults to 5000ms. You can also cap the points an account can hold with max_points, or turn rate limiting off entirely by setting active to false.
To confirm the configuration file is valid, start the node with chr node start, then read the config back with chr query ft4.get_config.
Create a user account
With the configuration in place, you can move on to registering a user account.
You will write an operation that creates an account holding 1000 tokens. First, add these imports to src/rell_marketplace/module.rell:
import lib.ft4.core.accounts.{ account, create_account_with_auth, single_sig_auth_descriptor };Then create the file src/rell_marketplace/accounts.rell with the following content:
operation create_user(pubkey) { val account = create_account_with_auth(single_sig_auth_descriptor(pubkey, set(["A", "T"]))); Unsafe.mint(account, dapp_meta.asset, 1000);}This operation creates an account for the given pubkey and attaches an auth descriptor carrying the flags A and T. As a result, the registered key can run administrator commands, such as adding or removing other auth descriptors, and can make transfers. The operation then mints 1000 tokens into the account. This setup exists only for testing and learning, which is why it skips any additional security measures around token and account creation.
To go deeper into working with auth descriptors and accounts, take the course Build a simple Chromia app with Rell and React.
The next lesson covers an NFT model, which represents the asset traded in the marketplace.