Skip to main content

Tokens

ERC-20 Tokens are fungible tokens (as opposed to non fungible tokens). They are ubitious across the Ethereum ecosystem. Common use cases include as money, commodities, financial assets, governance tokens, and revenue share tokens. But really, an ERC20 token can be used for whatever it's design to be used for. In workshop 1, we'll cover ERC-20 (how ICO works); decentralized exchange - Uniswap (how to swap ETH for some ERC-20 tokens); and stablecoin (DAI and USDC are all ERC-20 tokens).

This is going to be a brief overview. For an in-depth understanding of these topics, recommend attending the DeFi track.

Here's an ERC20 written in psudo-python, called FreeCoin, designed to be free for anyone mint in unlimited amounts. It's not recommended to use this token as a real currency.

class FreeCoin():    def init():        self.balances = {} # empty dictionary, key will be user, value will be balance
    def transferTo(recipient, amount):        # caller is a keyword that represents who called the function        if self.balances[caller] > amount:            self.balances[caller] -= amount            self.balances[recipient] += amount
    def balanceOf(user):        return self.balances[user]
    def mint(amount):        self.balances[caller] += amount

Examples of Real-life Tokens#

USDC (US Dollar Coin). Each USDC is minted by Circle (Coinbase and friends). Circle puts a real US dollar a trust, then mints a USDC. A USDC is always redeemable for $1 so it's a useful way of keeping your money in crypto, without experiencing the daily volatility of ETH. (USDCv2: upgrading a multi-billion dollar ERC-20 token)

DAI. This is another stable coin similar to USDC. However, each DAI is redeemable for $1 worth of ETH. This mechanism allows DAI to always be worth $1 and is interesting to read about. One benefit of DAI over USDC is that with DAI, you don't need to trust Circle's honesty, however the caveat is that with DAI you now need to trust/verify that the smart contracts are written properly. How it works video How it works slides

MKR (Maker). In order for the DAI protocol to keep running smoothly, a governance community called Maker adjusts parameters for the DAI ecosystem. MKR holders vote on how to adjust the DAI protocol to keep the trains running. Awesome MakerDAO

WBTC (Wrapped Bitcoin). This token functions similarly to USDC, but instead of being redeemable for $1, it's redeemable for 1 Bitcoin. Since bitcoin isn't an ERC20 built on Ethereum you can't use Bitcoin in the Ethereum ecosystem. WBTC solves this!

UNI. A governance token for Uniswap. Owning this token gives you voting rights in how Uniswap spends its multibillion dollar treasury. UNI token holders also can vote to turn on a fee switch which will direct a small portion of Uniswap trading fees to the treasury. Announcing UNI

MCO2. The Moss Carbon Credit is a commodity. 1 MCO2 Token = 1 carbon credit from a VCS certified environmental project (forestry, energy, biomass, etc). Practically, buying then burning an MCO2 token is offsetting your carbon emissions by 1 ton. These tokens are all minted by Moss so you're trusting that they've taken care of the legalities. Read more

If you want to get technical, here's the official token standard. This document describes what methods you need to implement for a valid ERC-20 token. ERC-20 token standard

Readings#

ERC-20 token standard

https://github.com/ethereum/EIPs/issues/20 - interesting to read through the original discussion thread

ERC-20 tutorial on ethereum.org with Web3.py example

ERC-20 ConsenSys implementation

ERC-20 OpenZeppelin implementation

Some examples of ERC-20 tokens:

UNI (Uniswap)

COMP (Compound)

DAI (Dai)

MKR (Maker)

BAT (Basic Attention Token)

WBTC (Wrapped BTC)

USDC (USDCv2: upgrading a multi-billion dollar ERC-20 token)

Filecoin is NOT an ERC20 token, here is more about the filecoin ICO

Metamask Tips and Trcks - Video, tips on advanced gas control and ledger

For checking current gas price

Interact with Smart Contracts on Etherscan - Etherscan blog

Solidity By Example - Use this as a reference to learn solidity

Quests#

  • Interact with smart contracts on etherscan
    • Get some ERC20 token, e.g. DAI (can swap your ETH for DAI on Uniswap, see the topic below on how);
    • Go to the ERC20 token smart contract page on etherscan, e.g. DAI contract page;
    • Go to Read Contract, try reading different fields, e.g. put your address as input to check balanceOf;
    • Go to Write Contract, use transfer to transfer some token to another address of yours;
    • Look at the transaction in etherscan;
    • Go to Read Contract again to verify the balanceOf changed for your other address.

ERC-721#

Readings#

ERC-721 token standard

The Anatomy of ERC721

ERC-721 tutorial on ethereum.org with Web3.py example

0xcert ERC721 - a reference implementation

CryptoKitties ERC-721 implementation (compatible with an earlier version of the standard)

(Optional) Learn how our last mystery smart contract works - CryptoKitties updated their geneScience smart contract, see how the contract works, and try to figure out how they updated it

(Related) ERC-1155 Multi Token Standard

Quests

  • Interact with smart contracts on etherscan
    • Get some ERC20 token, e.g. DAI (can swap your ETH for DAI on Uniswap, see 01/05 reading list);
    • Go to the ERC20 token smart contract page on etherscan, e.g. DAI contract page;
    • Go to Read Contract, try reading different fields, e.g. put your address as input to check balanceOf;
    • Go to Write Contract, use transfer to transfer some token to another address of yours;
    • Look at the transaction in etherscan;
    • Go to Read Contract again to verify the balanceOf changed for your other address.
  • Reserve an ENS (Ethereum Name Service) name and link it to your Ethereum address.
  • Mint some DAI - There's a "see how it works" video on the website
  • (Optional) Coinbase earn - Earning MKR by watching videos