- To create an ERC20-based token in Ethereum, you need to follow a certain standard. The contract should include the following functions:
- totalSupply()
- balanceOf(address _owner)
- transfer(address _to, uint256 _value)
- transferFrom(address _from, address _to, uint256 _value)
- approve(address _spender, uint256 _value)
- allowance(address _owner, address _spender)
It should also include these events:
-
- transfer(address indexed _from, address indexed _to, uint256 _value)
- approval(address indexed _owner, address indexed _spender, uint256 _value)
We will discuss each function and event in detail throughout this chapter.
- Create a contract with the target compiler version and a name:
pragma solidity ^0.4.23;contract ERC20 { ..