How To Create A Mintable BEP20 or ERC20 Token

FacebooktwitterredditlinkedinmailFacebooktwitterredditlinkedinmail

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.

Mintable Token

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.

Mintable Token in Remix
Copy the transaction hash

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 contractsPut 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.

constructor code

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.

Add minter

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.

Minting tokens

Once you have minted coins, the coin and its ticker will show up at the contract address.

STINK Ticker

Here’s a link to the published and verified contract of STINK: https://testnet.bscscan.com/address/0x831b05f80339e8d8b8aa59db1e166392618262f3


Promoted Exchanges

Note: Investing and trading with cryptocurrencies can result in significant loss

Binance and Crypto.com offer everything you need, along with a $20 welcome bonus.

freebtc

BitPanda is the easiest cryptotrading platform, and perfect for the beginner.

ExpressVPN is the fastest and most secure on the market. Try it for FREE for 30 days!

youtubeinstagramyoutubeinstagram

FacebooktwitterredditlinkedinmailFacebooktwitterredditlinkedinmail