Skip to content

Commit d88d679

Browse files
committed
translate task 6
1 parent 2118635 commit d88d679

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

basic/06-ethersjs-waffle/README-en.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
## Preface
2+
3+
Waffle is a smart contract test library that adapts to ehter.js. This example demonstrates the basic process and usage of Waffle test.
4+
You can refer to the offical website of Waffle width the detailed usage(https://ethereum-waffle.readthedocs.io/en/latest/getting-started.html).If you are a developler not familiar with Waffle, you could read the sample code and do exercises, then refer to the official website for a more in-depth understanding.
5+
6+
## Contracts Introduction
7+
8+
- contract/SimpleToken.sol
9+
A standard ERC20 contract that implements all interface of ERC20. Users could issue ERC20 tokens using this contract.
10+

11+
12+
## Scripts Introduction
13+
14+
- test/simpleTokenTest.js
15+
The unit test code of SimpleToken.sol contract. There is only one test script here, you could write multiple scripts of unit test codes for different contracts under the "test" directory during the development.
16+
Each interface of SimpleToken.sol contract will be simplely tested in the simpleTokenTest.js script.You can refer to the sample to write unit test codes of other contracts.
17+
18+
- index.js
19+
External contracts needs to be invoked separately. When unit test is passed, the script could be called to generate some actions in the production environment.
20+
21+
## steps
22+
23+
- 1 install dependencies
24+
25+
```bash
26+
yarn install
27+
```
28+
29+
- 2 compile contracts
30+
31+
```bash
32+
yarn build
33+
```
34+
35+
- 3 config environment variables
36+
37+
```bash
38+
cp .env.example .env
39+
40+
## modify PRIVATE_KEY and INFURA_ID in .env
41+
```
42+
43+
- 4 Test Execution
44+
45+
```bash
46+
yarn test
47+
```
48+
49+
- 5 test index.js
50+
51+
```bash
52+
node index.js
53+
```
54+
55+
## Note
56+
57+
when it hint that "cannot find yarn commands"(when running on VMWare), you can try:
58+
59+
1. $ sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.rep
60+
2. $ sudo yum install yarn
61+
62+
check yarn version
63+
$ yarn --versionyarn --version
64+
65+
- If run `yarn test` on windows, you should change the "export" keyword to the "set" keyword in the "test" command of the "scripts" key of the file named package.json
66+
67+
Before changed:
68+
69+
```
70+
"scripts": {
71+
"build": "waffle",
72+
"test": "export NODE_ENV=test && mocha --timeout 10000"
73+
},
74+
```
75+
76+
afer changed:
77+
78+
```
79+
"scripts": {
80+
"build": "waffle",
81+
"test": "set NODE_ENV=test && mocha --timeout 10000"
82+
},
83+
```
84+
85+
## Reference document
86+
87+
88+
- waffle offical document: <https://ethereum-waffle.readthedocs.io/en/latest/getting-started.html>
89+
90+
- etherjs offical document: <https://docs.ethers.io/v4/api-providers.html>
91+
<https://docs.ethers.io/v5/getting-started/#getting-started--contracts>
92+
93+
- Chinese document: <https://learnblockchain.cn/docs/ethers.js/api-providers.html>

0 commit comments

Comments
 (0)