Besides making a regular coin, as described in an earlier post, it is also possible to create a coin which allows you to mint new tokens as you see fit. A mintable token is just a token that you can create more of, either as the owner of the contract or in an automated manner.
The coin we are creating is going to be mintable by the person or the persons who have been assigned the minter role. The contract will leave the ownership to whichever address deploys it, and from there the owner can assign or revoke minter roles to other people.
The full code we will be using can be found here: https://gist.github.com
Creating A Mintable ERC20 or BEP20 Token Using Remix
Create a new token in Remix and compile it.
At the deployment screen, type the name, symbol and initial supply for the token. Remember the decimals when you set the initial supply, so you set the initial supply + the number of decimals (for example 100,000 coins with 18 decimals will be set as 100000000000000000000000). When you are satisfied, click on “transact” and confirm in metamask.
Check the bottom of the screen for information related to the deployment, copy the hash and search for it in whichever blockchain you deployed the contract on.
When you check the contract in the blockchain explorer (in this case https://testnet.bscscan.com/), you will once again have to verify the contract before you can interact with it. Click “verify and publish”.
The verification of the contract works as with the previous contracts. Put the correct compiler and license information when promted, and at the next page paste the source code in the designated area and finally copy the marked code and paste it in the field for constructor argument.
If you did everything correctly the contract will be verified and you can connect your metamask. Once you have connected with metamask (using the same address as you deployed the contract with), you have the option to add more minters.
This new minter (as well as the owner) can now create coins which will be sent to the specified address. And again, you have to add as many zeros as there is decimals. So when I mint 10 000 coins to an address, I have to write “10000000000000000000000” for it to be correct.
Once you have minted coins, the coin and its ticker will show up at the contract address.
Here’s a link to the published and verified contract of STINK: https://testnet.bscscan.com/address/0x831b05f80339e8d8b8aa59db1e166392618262f3
Note: Investing and trading with cryptocurrencies can result in significant loss