Chromia
Start Building

06 / 16Module 2: The blockchain dappIntermediate

Account management

This lesson shows you how to build account management with FT4: you write operations that register new accounts and control account permissions.

Account authentication

The main module contains an authentication handler, which sets the permissions each operation requires.

Account registration relies on the Open Strategy. With it, any caller can invoke the register_account() operation and create an account with no restrictions. To enable it, add import lib.ft4.accounts.strategies.open to the main file so that registration uses the Open Strategy.

src/main.rell
module;import lib.ft4.auth;import lib.ft4.accounts.strategies.open;import lib.ft4.core.accounts.{ account, Account, create_account_with_auth, single_sig_auth_descriptor };@extend(auth.auth_handler)function () = auth.add_auth_handler(    flags = ["T"]);

An auth descriptor defines who can access an account and which actions they may perform. The T flag gives accounts transfer permissions, which the asset management system depends on. For background, read the FT4 accounts overview. For the full list of strategies and how each one is implemented, see Account Registration Framework in the Chromia docs.

Written for this site from Chromia’s public course. Code samples are the course’s own.