ERC-20 tokens are the most basic and essential concept in Ethereum. This tutorial focuses on deploying smart contracts written in Solidity to different public chains. It is hoped that everyone can learn to deploy smart contracts on the public chain without requiring specific contract concepts to interact. This tutorial takes deployment on the Goerli public chain as an example.
Switch to the target network where you want to mint tokens in your wallet.
Open Remix
Remix IDE address
Create a new file and paste the following OpenZeppelin ERC-20 contract link:
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666941823-514054-image.png]
- After saving the file, you will see a bunch of files imported into Remix. Find the ERC20 PresetMinterPauser.sol file in the presets. This file is written by OpenZeppelin according to the ERC20 standard with minter functionality. After deploying this file, you will become the owner of the contract and thus have the permission and ability to mint tokens.
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943056-941661-image.png]
- Go to the [Deployment] tab in Remix, select "Injected Provider - Metamask" in [Environment], and select "ERC20 PresetMinterPauser.sol" in [Contract].
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943217-867099-image.png]
- Click on the drop-down menu at [Contract], fill in your token name and symbol ("TEST" and "TST" for example), and click "transact".
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943256-961678-image.png]
- Confirm the transaction that pops up.
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943302-963946-image.png]
- The Remix console will show that the contract is deployed successfully, and you can see the successful deployment information in [Deployed Contracts].
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943330-414388-image.png]
- Click here to copy contract address at [Deployed Contract]
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943362-445491-image.png]
Click "Import Tokens" in the wallet, select "Custom token", import the copied contract address, then click "Add custom token" and confirm the import.
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943395-800846-image.png]
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943426-7944-image.png]
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943450-38288-image.png]
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943465-566755-image.png]
You can see in the wallet that the balance of the issued tokens is 0. At this time, you need to return to Remix to execute the token issuance.
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943520-120426-image.png]
Click on the drop-down menu at [Deployed Contracts] of Remix, find "mint" and click on it.
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943562-488201-image.png]
- Fill in your wallet address in "address", and the number of tokens to be issued in "uint256". Note that the unit here is wei. If you mint 1000 test tokens, you need to enter "1000000000000000000000" (the number of "0" is 18+3);
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943539-584818-image.png]
- Click "transact" and confirm the pop-up transaction window from your wallet. After the transaction is confirmed, you will see 1000 test tokens in the wallet.
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943609-888501-image.png]
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943630-280413-image.png]
[upl-image-preview url=https://talk.comunion.org/assets/files/2022-10-28/1666943644-360160-image.png]