Implementation

State Variables

  • bool public isTransferable Determines whether token transfers (beyond minting) are allowed.

  • bool public isOutsideTransferAllowed If true, tokens may be transferred to any address. If false, tokens can only be transferred to addresses that already hold tokens.

  • uint256 public materialContributionWeight The multiplier applied to the materialContribution when minting new tokens.

  • uint256 private adminCount Tracks the number of current admins to prevent removing the last admin.

  • mapping(address => bool) private hasReceivedTokens Tracks if an address has ever received tokens (either via mint or transfer).

  • mapping(address => uint256) private firstMintTime Records the block timestamp of the first time an address received tokens.

Functions

Constructor

constructor(
    address initialOwner,
    bool _isTransferable,
    bool _isOutsideTransferAllowed,
    uint256 _materialWeight,
    string memory name,
    string memory symbol
) ERC20(name, symbol)
  • Parameters:

    • initialOwner: Address to receive the ADMIN_ROLE.

      • _isTransferable: Initial setting for enabling or disabling transfers.

      • _isOutsideTransferAllowed: Initial setting for allowing or disallowing transfers to addresses that do not yet hold tokens.

      • _materialWeight: Initial multiplier for material contributions.

      • name: ERC20 token name.

      • symbol: ERC20 token symbol.

Mint

Mints new tokens to a specified address. Calculation:

  • If firstMintTime[to] is 0, it is set to the current block timestamp.

  • Requires ADMIN_ROLE.

Batch Mint

Mints new tokens to all the specified addresses, calculating the material and time contribution for each recipient.

Update Settings

Updates the settings used for the calculations of the team points amount in the mint function.

Add Admin

Adds a new admin. Can be called only by other admins. It is mandatory for the new admin to already be a token holder, otherwise it will fail.

Remove Admin

Removes an admin. Can be called only by other admins. It ensures that the admin being removed is not the only admin in the organization, so the organization won't be locked.

Check Is Admin

Public view function that can be called by anyone, returns true if the address passed as parameter is an admin in the organization.

Last updated