How To Create an ERC-20 Token on Ethereum (ETH): Step-by-Step Manual by GetBlock
GetBlock, a top-tier provider of blockchain nodes, introduces this brief guide on how to create an ERC 20 token. As this standard is the most popular token design on Ethereum (ETH) and all blockchains that are compatible with Ethereum Virtual Machine (EVM), making ERC 20 tokens could be the first step toward Web 3.
How to create ERC20 token: Detailed guide
ERC-20 tokens are useful general-purpose tools for digital economies. Now is the appropriate time to learn how to make a token on the Ethereum blockchain, ETH.
1. Start with Remix
For this tutorial, we'll be using Remix, a web interface commonly used to write and deploy Ethereum smart contracts. First, we need to open an integrated development environment.
In Remix, we start by selecting the “Start coding online” option. This creates a GetBlock_Token workspace in the upper left corner.
2. Sign up on GetBlock and connect to Goerli
To get our code to work, we need to connect it to a blockchain. Connecting our code to a blockchain requires establishing a bridge between application nodes and blockchain nodes. Since we're creating ERC20 tokens on the Ethereum blockchain, Etheruem's nodes are the appropriate connection point.
Ethereum has multiple testnets, which are essentially sandbox networks that resemble the technical specifications of the Ethereum mainnet. We decided to use one of these testnets in our experiment to make it more affordable. The name of the testnet we used was Kovan.
GetBlock provides a secure connection to the Ethereum testnet, known as Goerli, in 2019. The ETH team launched Goerli as a testnet.
Before using GetBlock, you must create an account and sign in. Next, choose the ‘Shared Nodes’ menu option and select ‘Ethereum’. Switch the button to ‘Testnet’ and choose ‘Goerli’ as the test network name.
In the?‘Endpoint’?list, we need to choose https-endpoint; here’s our endpoint to Ethereum’s testnet Goerli.
3. Connect Metamask to Goerli Testnet
The Metamask wallet is the most popular option for Ethereum tokens. First, people need to install the wallet through a Chrome browser plug-in. Then they need to add Goerli to their Metamask wallet.
Before adding Goerli as a network, you must select ‘Add Network’ from the list of available networks. Then you can specify the parameters for Goerli in the following fields:
In the list of networks available, we need to choose ‘Add Network’ and set the parameters of Goerli:
That’s it, now the wallet supports Goerli as one of its chains.
After you need testnet money from a faucet. A Paradigm XYZ faucet is available at https://faucet.paradigm.xyz/. However, you need to have a verified Twitter account to obtain funds from this faucet.
领英推荐
4. Import the code from OpenZepellin
In order to streamline the process of development, we can take almost ready-made code standards for ERC-20 tokens from OpenZepellin. OpenZepellin Contracts is a library for smart contracts building: its collection of code templates features a plethora of patterns for various use-cases.
Here’s how the standard for ERC-20 token looks like (‘GLDToken’, ‘GLD’, and ‘Gold’ are the names for the token we’re experiment with):
// contracts/GLDToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract GLDToken is ERC20 {
????constructor(uint256 initialSupply) ERC20("GETBLOCK_TEST", "GBT") {
????????_mint(msg.sender, initialSupply);
????}
}
We can take it and run it in Remix:
Clicking the button in the bottom left of the screen labeled with the Solidity programming language logo launches a compiler program. This program converts source code from other programming languages into machine or byte code. Then, this data can be stored on the blockchain and accessed whenever necessary.
Now we can deploy our code. To do this, we can enter the Deployment menu next to the compiler menu. In the Environment field, we should select Injected Provider; this is because we're working with the Goerli testnet. Additionally, we should enter the address of our account in the field labeled Account Address.
Etherscan is an example of an Ethereum explorer where you can track your token.
Now we can track our token (contract)?0x4E8fBD0d754a9D06D7B202DA18458FDE1Ba9487f?in Goerli?testnet.
Final thoughts
Using Ethereum’s ERC20 token standard allows us to deploy tokens on the largest smart contract platform in existence. Doing so unlocks many opportunities; it allows people to create entire digital economic systems from scratch.