Implementation
State Variables
bool public isTransferable
Determines whether token transfers (beyond minting) are allowed.bool public isOutsideTransferAllowed
Iftrue
, tokens may be transferred to any address. Iffalse
, tokens can only be transferred to addresses that already hold tokens.uint256 public materialContributionWeight
The multiplier applied to thematerialContribution
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
Parameters:
initialOwner
: Address to receive theADMIN_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]
is0
, 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