Question about Minting the token

Hello lovely people

am relatively new to Solidity and going through rough learning curve.

I have question about minting my bep20 token,

at the time of deployment, the deployer or (msg.sender) will mint 100% of the total supply and the token will be transferred to his wallet

here is the constructor with emit Transfer event am using :

constructor() public {
    _name = {{TOKEN_NAME}};
    _symbol = {{TOKEN_SYMBOL}};
    _decimals = {{DECIMALS}};
    _totalSupply = {{TOTAL_SUPPLY}};
    _balances[msg.sender] = _totalSupply;

    emit Transfer(address(0), msg.sender, _totalSupply);

my question is can I keep the total supply of the token stored in the token smart contract ( without minting at the time of deployment ) and then use "write to contract function" whenever I want to mint token?

or its mandatory to mint all the total supply at the time the constructor run for first time ?


Hi, welcome! :wave:

No, it is up to you. You can do as above, or you can mint no matter when you want.
You can have a look at this contract: ERC20PresetMinterPauser.sol, it can mint tokens whenever you want.


Amazing, thank you
That solved my issue