TokenMint Blog

Mintable ERC20 Token Explained

Mintable ERC20 Token

This short tutorial will explain what mintable ERC20 tokens are, what is the difference between minting and mining, what is Minter role and how to add, remove and transfer it. You'll find out what are some successful mintable ERC20 token projects, and how mintable tokens are used in crowdsales.

Mintable tokens can be created using our ERC20 token generator tool. If you want to learn about Ethereum tokens, we recommend you create one, and try it out. It's free when you are using Ropsten testnet. Take a look at create tokens page to learn how to create one.

In this tutorial, we are going to talk about OpenZeppelin's implementation of Mintable token which is battle-tested framework and used by our token generator.

What Are Mintable Tokens?

Mintable tokens are ERC20-compatible tokens with one added feature: new tokens can be created at any time and added to total supply. Standard ERC20 tokens don't have this feature, which makes them a fixed supply tokens.

Mint function is defined like this in Solidity:
function mint(address to, uint256 value) public onlyMinter returns (bool)
New tokens can be minted only by an address which is set to be in a Minter role. If no address is in Minter role, then no one can create new tokens.

Minter Role

Minter role is an address that has a special privilege to create new tokens, thus adding them to total supply. There could be multiple Minter role addresses, but in practice, it's usually just one address. The first Minter is the address that deployed the token contract. Current minter can add new minter, renonunce his privilege to be minter, or transfer his right to other address.

Adding New Minter

When a Minter wants to add another Minter, he can call the following function:
function addMinter(address account) public onlyMinter
We can see that by using function modifier onlyMinter only current Minter can add a new Minter. Calling addMinter function emits the following event:
event MinterAdded(address indexed account)

Renouncing Minter Role

Current Minter can renounce his privilege by calling the following function:
function renounceMinter() public
Only address that is Minter can renounce itself from Minter role, no one else. Calling renounceMinter function emits the following event:
event MinterRemoved(address indexed account)

Transfering Minter Role

Current Minter can transfer his privilege by calling the following function:
function transferMinterRole(address newMinter) public
Function transferMinterRole adds new minter and renounces Minter role privilege in one transaction. It emits both MinterAdded and MinterRemoved events.

Minting vs Mining

Minting is not the same as mining. This is a common misunderstanding when people are talking about cryptocurrencies.

Minting tokens is done by sending a transaction that creates new tokens inside of token smart contract. As we have seen in What are mintable tokens, a call to a smart contract function can create unlimited number of tokens, without spending energy.

On the other hand, mining does create new tokens, but is usually limited as per concensus rules of that blockchain, and requires spending energy. Mining also serves other purposes like securing the network and packing new transactions into blocks.

Mintable Token Examples

There are plenty of mintable ERC20 tokens out there. Here are some of the more interesting tokens.

Dai (DAI)

DAI is decentralized stablecoin pegged to $1 USD used in the MakerDAO system. Users can lock their crypto assets (ETH) inside of MakerDAO contract, and in return get DAI tokens. Everytime ETH is locked in CDP (Collateralized Debt Position), new DAI tokens are minted by the MakerDAO contract.

Status (SNT)

Status is an open-source platform which uses it's native SNT token as a mechanism for governance of the Status client, as a utility token to drive push notifications in their messaging app, as well as for curation of user-generated content on their network. The SNT token has a cap on total supply, but a lower current circulating supply. New tokens can be minted by the controler address.

Decentraland (MANA)

Decentraland is a virtual world platform owned by its users. Users create goods and services and trade them using MANA tokens. MANA tokens are mintable and burnable ERC20 tokens.

Mintable Tokens in Crowdsales

Mintable tokens are widely used in combination with crowdsales. Crowdsale contracts are used to create an ICO where ERC20 tokens are sold for ETH. Here's the mechanism used for combining mintable tokens with crowdsale:

  1. ICO maker deploys mintable token contract, giving him a Minter role
  2. ICO maker deploys crowdsale contract
  3. ICO maker transfers Minter role to crowdsale contract. Only crowdsale contract can mint new tokens.
Now, the crowdsale begins. Investor comes along and wants to invest in new tokens. He sends ETH to crowdsale contract, contract mints brand new ERC20 tokens at current price and sends them to investor. When crowdsale is finished, no one can mint more ERC20 tokens, not even crowdsale contract, since it's coded that way. Investors can be sure that no one can dilute their share of token holdings.

Share This Post

What's Next

If you've completed this tutorial, we recommend you follow up with these tutorials:

How to Mint New Tokens Using Etherscan
Fixed Supply ERC20 Tokens Explained
Ethereum Wallets For Mintable ERC20 Tokens
How to Add Mintable Token to Metamask Wallet

Connect With Us

Thank you for reading this far! You can:
- follow us on Twitter
- subscribe to our channel on Youtube

Contact us

We are Merkle Blue DOO, a blockchain startup.

Vardarska 1c/54, 21000 Novi Sad, Serbia

Phone: (+381 64 321 2640)