Implementing a Fixed Supply Token with Ownership Controls in Sway and Fuel

I’m exploring the possibility of implementing a fixed supply token in Sway and Fuel with specific features related to ownership and control. I would like to know if the following functionalities can be effectively implemented in Sway and Fuel:

  1. Fixed Supply Initialization: The token should have a fixed initial supply minted to the owner upon deployment.
  2. Token Metadata: There should be a way to store and retrieve token metadata, similar to a token URI.
  3. Ownership Controls: The contract should restrict certain actions to the owner. For example, transfers should only be allowed if a specific condition (like a launch) is met.
  4. Launch Mechanism: There should be a mechanism to enable or disable certain functionalities, like transferring tokens, based on the contract’s state.
  5. Transfer Restrictions: Before the token is in the desired state (e.g., launched), certain operations should be restricted.

Given the UTXO model and the specific constructs in Sway and Fuel, can these features be implemented effectively? Are there any best practices or considerations I should be aware of when designing this contract in Sway and Fuel?

Thanks!

hey @Pranav2456, yes you can implement a token with the above requirements.

  1. fixed supply: you can initialize a fixed supply of tokens and mint them to the owner upon deployment.
  2. token metadata: You can store and retrieve token metadata using a storage map.
  3. Ownership Controls: You can restrict certain actions to the owner using the Ownership Library from sway_libs
  4. Launch Mechanism: you can maintain a state to enable or disable the functionalities.
  5. Transfer Restrictions: you can use the above-declared state to restrict the transfer mechanisms

you can follow our sway applications repo for such examples and can refer to our docs.

You can also use our sway playground to write and test contracts on the go or even use the contracts boilerplate