0PricingLogin
Web3 & DApp Development Fundamentals · Lesson

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

  1. The ERC-20 Standard
  2. Implementing a Token
  3. Allowances
  4. Minting and Burning
← Back to Web3 & DApp Development Fundamentals