How to add max supply to a mintable ERC20 token on Polygon chain

Good afternoon,

I am having some trouble figuring out how to add a maximum supply to a mintable token for a yield farm.

I am using Remix.

The token is forked from Gatorswap

you can set up a variable with the maximum supply and check on mint if current supply + mint is <= max supply?

another way is to premint total supply and reward from masterchef transfers instead of mints.

1 Like

Good morning,

I am rather new to coding and im still struggling with some stuff,

Could you be so kind to paste me the code necessary to implement the maximum supply with the mint function?

Masterchef is calling the mint from the token adress, so that function should be added in to token contract or the masterchef?

Do you mean you want to a capped token? you can have a look at this token:
openzeppelin-contracts/ERC20Capped.sol | OpenZeppelin/openzeppelin-contracts

1 Like

yea thats a good code for cap.