How to implement a no-code deployment of an ERC20 token using Remix and OpenZeppelin
Preparation
Before you start with the actual deployment of the ERC20 token, there are a few preparatory steps you need to follow:
-
Install MetaMask here (opens in a new tab).
-
Get Some Test FLA here (opens in a new tab).
-
Add FLA Testnet here.
Step 1: Create a new file
Create a file named erc20.sol
in the contracts directory.
Step 2: Paste the Code and Modify Parameters
Copy and paste the following Solidity code into the erc20.sol
file. This code imports the OpenZeppelin ERC20 contract and sets up a basic ERC20 token:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken is ERC20 {
constructor() ERC20("MyTokenName", "MTK") {
_mint(msg.sender, 10000 * (10 ** uint256(decimals())));
}
}
Change the parameters in the constructor to customize the token:
-
name: The name of your token.
MyTokenName
-
symbol: The symbol of your token.
MTK
-
initialSupply: The initial supply of your token
10000
(in whole units, it will be multiplied by 10^decimals() within the contract).
In this example, the token name is "MyTokenName", the symbol is "MTK", and the initial supply is 10,000 tokens.
For example
Deploy a token with:
-
name: LaughCoin
-
symbol: LOL
-
initialSupply: 100000000
Step 3: Compile the Contract
-
Click on the "Solidity Compiler" tab on the left sidebar.
-
Select the appropriate compiler version (0.8.x).
-
Click on "Advanced Configurations" to expand the advanced settings.
-
Choose EVM Version "paris".
-
Click "Compile erc20.sol".
Step 4: Deploy the Contract
-
Click on the "Deploy & Run Transactions" tab on the left sidebar.
-
Set the environment to "Injected Web3" if you are using MetaMask, or "JavaScript VM" for a simulated environment.
-
Click "Deploy".
Step 5: Expand the Deployed Contract
-
In the "Deployed Contracts" section, find the contract you just deployed.
-
Click on the contract name to expand it. This will show you a list of available functions and variables that you can interact with.