How to create a capped BEP20 token

Hey, I’m trying to create a mintable and burnable token but with a limited supply.
So for example initial supply is 1 000 000, you can burn and mint. But the maximum supply is 10 000 000.
I don’t find anything about this online.

You can try using a “require” statement inside mint function where you check if the total supply is under 10.000.000

    require(totSupply < 10000000, 'Maximum supply Reached');
1 Like

There is two ways to do this. One is to create a token that someone can mint, but could never mint more than the cap. You can use ERC20Capped for this (though you should be aware of issue

The other is to create a non-mintable token, and premint all of the supply in the constructor to some account that will be in charge of distributing the supply.

Okay thank you but can we use ERC20Capped for BEP20 token ?

I am not familiar with BEP20. I assume you can.

Okay, I’ll take a look thanks!