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.
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"
Property | Description |
---|---|
sender_blockchain | The 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. |
sender | The sender property defines who can send tokens to the dapp. The value "*" allows everyone to send tokens. |
recipient | The recipient property defines who can receive tokens in the dapp. The value "*" indicates that everyone can receive tokens. |
name | The name property represents the name of the asset required for account registration. |
min_amount | The min_amount property sets a minimum threshold for the transfer to a non-existent account for registration purposes. |
timeout_days | The timeout_days property specifies the period in days during which a user can claim a non-existing account with a balance. |
strategy | The strategy configures the strategy type used for the registration process. |
Please refer to the tests for testing the above configuration.