Implementing a Token
transfer and approve.
Building a Token
Now you will implement the core of an ERC-20 token from scratch. Understanding the internals helps you debug and audit real tokens, even when you later use libraries.
We will focus on the state, transfer, and approve.
Core State Variables
A token needs to track balances and total supply. Balances are stored in a mapping from address to amount.
<code>contract Token {
string public name = 'MyToken';
string public symbol = 'MTK';
uint8 public decimals = 18;
uint256 public totalSupply;
mapping(address => uint256) public balanceOf;
}</code>All lessons in this course
- The ERC-20 Standard
- Implementing a Token
- Allowances
- Minting and Burning