中文 / English
This demo shows the procedure for creating an ERC20 contract using ethers.js
Difference between web3.js and ethers.js can be seen here
-
Deploy an
ERC20contract Deploying by usingdepoly.js. In this demo, we use the test networkGoerlito deploy the contract, and we need to use an account with Ether to send the transaction. -
Call the contract Call
transfer,balanceoffunctions of the contract, and check the result. -
Listen to events Listen
Transferevents by usingproviderContract.onceandproviderContract.on
-
Install dependencies
npm install
-
Config
.envcp .env.example .env # replace the xxx and yyy with your own key PRIVATE_KEY=xxxxxxxxxxxxxxxx INFURA_ID=yyyyyyyy -
Run it
node index.js
Official documentation:
- https://docs.ethers.io/v4/api-providers.html
- https://docs.ethers.io/v5/getting-started/#getting-started--contracts
Other resources(Chinese):