ERC-20 Token

Overview​

This will follow very closely with the steps to deploy an ERC-20 token to Ethereum. An ERC-20 token is a token that follows the ERC-20 Standard. To follow the standard, we will be deploying a contract that implements the following events and functions:

function name() public view returns (string)
function symbol() public view returns (string)
function decimals() public view returns (uint8)
function totalSupply() public view returns (uint256)
function balanceOf(address _owner) public view returns (uint256 balance)
function transfer(address _to, uint256 _value) public returns (bool success)
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success)
function approve(address _spender, uint256 _value) public returns (bool success)
function allowance(address _owner, address _spender) public view returns (uint256 remaining)

event Transfer(address indexed _from, address indexed _to, uint256 _value)
event Approval(address indexed _owner, address indexed _spender, uint256 _value)

For this tutorial, we are going to be using Hardhat.

Prerequisites​

To follow along, it's recommended to review and be familiar with the documentation on deploying a contract. This will also follow a lot of the same steps as the Launching an ERC-721 (NFT). You will also need to have a working Node.js >=16.0 installation and a small amount of VLCT for gas.

Also, take a look at these important points to consider before creating your token.

Step 1: Set up your Environment​

For this tutorial, we're going to use npm and Solidity v0.8.9

Select Create an empty hardhat.config.js and hit enter. Then run:

Configure hardhat with Velocity.

Step 2: Add Contract Code​

We're going to import and use OpenZeppelin's ERC-20 contract implementation.

Now add the following code to your ExampleErc20.sol file:

Now, you are ready to deploy your token contract. Be sure to properly store your mnemonic/private key! The deploy script will be the same as when we deployed the NFT. Also, see here for more info on deploying contracts with Hardhat.

Last updated