Skip to main content

Open strategy

Developers can use the open strategy to create a registration process that does not require users to pay any fees. In this method, users must transfer a specific amount of tokens to a non-existent account, which they must then claim to activate it. The non-existent account represents an empty account that needs to be funded with tokens. Once activated, users can utilize the tokens sent to the account. The registration process relies on the register_account function.

warning

Please note that it is advisable to use the open strategy only during the development phase. Using it outside of this phase may result in users registering accounts without paying any fees, potentially causing network spam.

Code example

To develop your dapp from the template, refer to the code examples and corresponding tests.

The following configuration defines the account registration process and should be added to the chromia.yml file:

lib.ft4.core.accounts.strategies.transfer:
rules:
- sender_blockchain: x"0000000000000000000000000000000000000000000000000000000000000000"
sender: "*"
recipient: "*"
asset:
- name: "MyTestAsset"
min_amount: 100L
timeout_days: 60
strategy:
- "open"
PropertyDescription
sender_blockchainThe property sender_blockchain is set to receive tokens from the blockchain with the BRID: x"0000000000000000000000000000000000000000000000000000000000000000". To receive tokens from all chains in the Chromia network, use the asterisk sign "*" as the value.
senderThe sender property defines who can send tokens to the dapp. The value "*" allows everyone to send tokens.
recipientThe recipient property defines who can receive tokens in the dapp. The value "*" indicates that everyone can receive tokens.
nameThe name property represents the name of the asset required for account registration.
min_amountThe min_amount property sets a minimum threshold for the transfer to a non-existent account for registration purposes.
timeout_daysThe timeout_days property specifies the period in days during which a user can claim a non-existing account with a balance.
strategyThe strategy configures the strategy type used for the registration process.
note

Please refer to the tests for testing the above configuration.