中文 / 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
ERC20
contract Deploying by usingdepoly.js
. In this demo, we use the test networkGoerli
to deploy the contract, and we need to use an account with Ether to send the transaction. -
Call the contract Call
transfer
,balanceof
functions of the contract, and check the result. -
Listen to events Listen
Transfer
events by usingproviderContract.once
andproviderContract.on
-
Install dependencies
npm install
-
Config
.env
cp .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):