With our recent release of Plugins, we also debuted the ability for creators to deploy their own ERC20 tokens in seconds on Mirror. And with not just any contract—this is the most finely tuned and efficient way to mint an ERC20 token around. To get started simply connect your wallet and enable the Tokens plugin.
To celebrate, we’re going to do a deep dive on the ins and outs of ERC20 Token minting on Mirror. In this post, we’ll look at how the ERC20 factory contract works on-chain in order to explain some of the advanced functionality available to power users. Additionally, we invite the broader web3 ecosystem to integrate our ERC20 token factory into their products, as we believe we’ve struck the right balance between token flexibility and low gas deployments necessary for a neutral and efficient public good primitive.
You can find the deployed contracts at:
ERC20Factory is a contract that facilitates the deployments of new ERC20 tokens for creators. The factory uses the EIP-1167 standard for simply and cheaply cloning contract functionality. Another benefit of using clones is that we can predict the address to which your token will deploy before submitting the transaction.
When you deploy a token with the ERC20Factory you will have the option to specify an owner and a total supply. The total supply will be minted to the owner’s wallet.
createfunction. Most parameters are self-explanatory. A few parameters to watch out for:
totalSupply_parameter needs to be specified in Wei; You can use Etherscan’s Unit Converter tool for this; simply type the decimal value you want in the
Etherbox and copy/paste the
Weivalue into the
decimalsparameter, we suggest using 18 decimals, as most ERC20 tokens use that.
nonceparameter, you need to pass in an integer; This parameter is used on the cloning functionality. For advanced details, see the Clones section below.
ERC20Deployedevent gives you information about your token deployment. The
cloneparameter is your token’s address.
The Mirror ERC20 implementation allows for creators to set a token owner, which is an Ethereum account/wallet that controls a few settings on the token. Token ownership can be transferred to any other address or renounced altogether, effectively making settings immutable. This means a token’s supply can be made fixed by renouncing ownership.
transferOwnership(address nextOwner_)specifying the new owner. After that, the new owner needs to call
owner can mint new tokens to any address and determine a “burn” setting. A burn setting determines whether the tokens can be burned. Burning reduces the circulating supply of a token, which affects its tokenomics. Token creators should have the ability to decide if their tokens can be burned.
mint(address to, uint256 value).
burn(uint256 value)to burn their own tokens.
You might be wondering, “Why would you want to burn your tokens?!” The answer to that is that it really depends on how want your token to be used. Burning tokens can facilitate different types of dynamics; For example, Mirror’s own $WRITE token uses the burning functionality to mint a new type of token in exchange -- an ENS domain with a
The Mirror ERC20 token supports EIP-2612, which allows users to grant token approvals with signatures that don’t incur gas fees.
ERC20Factory uses the EIP-1167 standard for simply and cheaply cloning contract functionality. When you deploy your ERC20 token, what you’re really doing is deploying a very small amount of code that will hold your token’s state (balances, name, symbol, etc.), but will delegate the code logic to a different address.
A benefit of using clones is that we can predict the address to which your token will deploy before submitting a transaction. To deploy a clone to a predictable address, we need to generate a unique
salt parameter. This parameter is generated using your wallet address, your token’s name, symbol, total supply, and the
nonce parameter. The
nonce parameter provides an extra amount of entropy to avoid collisions when generating the
salt parameter. For this reason, you can choose any integer as the value for
nonce as long as you have not previously deployed a token with the exact same parameters.
We’re excited to continue creating powerful and focused plugins like Tokens. To stay in the loop make sure to follow Mirror on Twitter. As always, you can get started anytime by simply connecting your wallet and installing the Token Plugin. Mirror is hiring!