AccessControl: best way to limit minting

Hello friends,
I am planning to release an ERC20 token as part of private and public sales.

Using the ERC20PresetMinterPauserUpgradeable preset.

Wondering about the best way to limit the number of total tokens so that participants can be sure no more than the advertised amount is ever minted.

Should I implement a max_supply and check for it in the mint() function?
Or mint the max supply after deploying and burn/lock the key of the MINTER_ROLE?

Thanks a lot

I believe there is an ERC20Capped for this case

1 Like

Hmm thatā€™s a good direction.
Let me thicken the plot :slight_smile:

My contract is already deployed but is upgradeable.

Do you know if it is possible to add ā€˜isERC20CappedUpgradeableā€™?

Since ERC20Capped addes little to ERC20, I would be surprised if it is not possible.