Skip to content

Latest commit

 

History

History
 
 

05-ethersjs-erc20

中文 / English

ethersjs-erc20

About this task

This demo shows the procedure for creating an ERC20 contract using ethers.js

Difference between web3.js and ethers.js can be seen here

Contents

  1. Deploy an ERC20 contract Deploying by using depoly.js. In this demo, we use the test network Goerli to deploy the contract, and we need to use an account with Ether to send the transaction.

  2. Call the contract Call transfer, balanceof functions of the contract, and check the result.

  3. Listen to events Listen Transfer events by using providerContract.once and providerContract.on

How to run this task

  1. Install dependencies

    npm install
  2. Config .env

    cp .env.example .env
    # replace the xxx and yyy with your own key
    PRIVATE_KEY=xxxxxxxxxxxxxxxx
    INFURA_ID=yyyyyyyy
  3. Run it

    node index.js

References

Official documentation:

Other resources(Chinese):