Skip to content

Commit 856a26d

Browse files
committed
fix network from rinkeby to goerli
1 parent d173d2c commit 856a26d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+195
-224
lines changed

basic/01-web3js-deploy/README-cn.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
- 本样例发送交易到 Infura , 需要创建相应的 Infura Project, 可以参考如下资料进行创建
66
https://ithelp.ithome.com.tw/articles/10202794 在成功创建 Infura Project 后,可以获取相应的PROJECT ID
77

8-
- 本样例中,需要自己来生成私钥。可通过多种方式来生成私钥。常见的方式是通过Metamask。可参考《精通以太坊》或其他文档安装: https://www.bookstack.cn/read/ethereum_book-zh/spilt.4.77adf5064f4455e8.md 安装完成后,连接到Kovan测试网络,点击账户详情-导出私钥,获得创建的测试账号的私钥PRIVATE_KEY。
8+
- 本样例中,需要自己来生成私钥。可通过多种方式来生成私钥。常见的方式是通过Metamask。可参考《精通以太坊》或其他文档安装: https://www.bookstack.cn/read/ethereum_book-zh/spilt.4.77adf5064f4455e8.md 安装完成后,连接到 Goerli 测试网络,点击账户详情-导出私钥,获得创建的测试账号的私钥PRIVATE_KEY。
99

10-
- 给Kovan测试网络中的测试账号充值。上一步开立的账号中,余额为0, 可通过faucets来充值: https://faucets.chain.link/kovan 每次冲入0.1Eth。
10+
- 给 goerli 测试网络中的测试账号充值。上一步开立的账号中,余额为0, 可通过faucets来充值: https://faucets.chain.link/ 每次冲入0.1Eth。
1111

1212
- 为方便代码测试, 在 .env 中放入私钥和Infura Project ID,格式为 "PRIVATE_KEY=xxxx" "INFURA_ID=yyyyyyyy", index.js代码会自动从中读取, 样例文件可参考 .env.example
1313

@@ -92,13 +92,13 @@ const abi = contractFile.abi;
9292

9393
4) 构造 web3 对象
9494
通过 web3 对象可以很方便的发送相应的交易到区块链网络, 同时获取区块链的处理结果.
95-
构造 web3 对象时, 主要需要传入一个参数, 就是对应的区块链网络, 包括 kovan, ropsten , rinkeby 等测试网络, 或是 mainnet 主网.
96-
这里我们使用 kovan 测试网络. 如果没有 kovan 网络的测试币, 可以切换到其他的测试网络.
95+
构造 web3 对象时, 主要需要传入一个参数, 就是对应的区块链网络, 包括 goerli 等测试网络, 或是 mainnet 主网.
96+
这里我们使用 goerli 测试网络. 如果没有 goerli 网络的测试币, 可以切换到其他的测试网络.
9797
同时需要注意的是, 这里我们通过 infura 向对应的区块链网络发送交易, 而 INFURA_ID 这个变量值也需要配置在 .env 文件中, 具体如何获取 infura_id, 可自行搜索查找相关文档
9898
```js
99-
// Create web3 with kovan provider,you can change kovan to other testnet
99+
// Create web3 with goerli provider,you can change goerli to other testnet
100100
const web3 = new Web3(
101-
"https://kovan.infura.io/v3/" + process.env.INFURA_ID
101+
"https://goerli.infura.io/v3/" + process.env.INFURA_ID
102102
);
103103
```
104104

basic/01-web3js-deploy/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
Through this basic task, you can learn the processes of compiling and deploying a smart contract, as well as learn how to use the basic APIs of `web3js`.
44

55
# Preparation
6-
- You need to create a project on [Infura](https://infura.io), and get the `PROJECT ID`, change your `ENDPOINTS` to `KOVAN`;
6+
- You need to create a project on [Infura](https://infura.io), and get the `PROJECT ID`, change your `ENDPOINTS` to `Goerli`;
77

88
- Create an account on `MetaMask`, which is a browser extension;
99
1. Get a wallet `address`, and the private key;
1010
2. Go `Settings` - `advanced` and open `Show test networks`;
11-
- Select `Kovan`, and record this address
12-
3. Top up your account through [faucets](https://faucets.chain.link/kovan) or others web services;
11+
- Select `Goerli`, and record this address
12+
3. Top up your account through [faucets](https://faucets.chain.link) or others web services;
1313
4. Wait for minutes, and see the balance on `MetaMask`
1414

1515
- Create a `.env` file, and add the following lines:
@@ -92,9 +92,9 @@ const abi = contractFile.abi;
9292
## 4. Create the `web3` instance
9393
`web3` is the main API of the `web3js` library. It is used to interact with the blockchain.
9494
```js
95-
// Create web3 with kovan provider,you can change kovan to other testnet
95+
// Create web3 with goerli provider,you can change goerli to other testnet
9696
const web3 = new Web3(
97-
"https://kovan.infura.io/v3/" + process.env.INFURA_ID
97+
"https://goerli.infura.io/v3/" + process.env.INFURA_ID
9898
);
9999
```
100100
| Note: The `INFURA_ID` is the `PROJECT ID` of the `Infura` project you created in **Preparation** part.

basic/01-web3js-deploy/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const contractFile = tempFile.contracts['Incrementer.sol']['Incrementer'];
3333
const bytecode = contractFile.evm.bytecode.object;
3434
const abi = contractFile.abi;
3535

36-
// Create web3 with kovan provider,you can change kovan to other testnet
37-
const web3 = new Web3('https://kovan.infura.io/v3/' + process.env.INFURA_ID);
36+
// Create web3 with goerli provider,you can change goerli to other testnet
37+
const web3 = new Web3('https://goerli.infura.io/v3/' + process.env.INFURA_ID);
3838

3939
// Create account from privatekey
4040
const account = web3.eth.accounts.privateKeyToAccount(privatekey);
@@ -67,8 +67,8 @@ const Deploy = async () => {
6767

6868
const deployReceipt = await web3.eth.sendSignedTransaction(deployTransaction.rawTransaction);
6969

70-
// Your deployed contrac can be viewed at: https://kovan.etherscan.io/address/${deployReceipt.contractAddress}
71-
// You can change kovan in above url to your selected testnet.
70+
// Your deployed contrac can be viewed at: https://goerli.etherscan.io/address/${deployReceipt.contractAddress}
71+
// You can change goerli in above url to your selected testnet.
7272
console.log(`Contract deployed at address: ${deployReceipt.contractAddress}`);
7373
};
7474

basic/02-web3js-transaction/README-cn.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ const privatekey = process.env.PRIVATE_KEY;
8888

8989
3) 构造 web3 对象
9090
通过 web3 对象可以很方便的发送相应的交易到区块链网络, 同时获取区块链的处理结果.
91-
构造 web3 对象时, 主要需要传入一个参数, 就是对应的区块链网络, 包括 kovan, ropsten , rinkeby 等测试网络, 或是 mainnet 主网.
92-
这里我们使用 kovan 测试网络. 如果没有 kovan 网络的测试币, 可以切换到其他的测试网络.
91+
构造 web3 对象时, 主要需要传入一个参数, 就是对应的区块链网络, 包括 goerli 测试网络, 或是 mainnet 主网.
92+
这里我们使用 goerli 测试网络. 如果没有 goerli 网络的测试币, 可以切换到其他的测试网络.
9393
同时需要注意的是, 这里我们通过 infura 向对应的区块链网络发送交易, 而 INFURA_ID 这个变量值也需要配置在 .env 文件中, 具体如何获取 infura_id, 可自行搜索查找相关文档
9494
```js
9595
// Provider
9696
const providerRPC = {
97-
development: "https://kovan.infura.io/v3/" + process.env.INFURA_ID,
97+
development: "https://goerli.infura.io/v3/" + process.env.INFURA_ID,
9898
moonbase: "https://rpc.testnet.moonbeam.network",
9999
};
100100
const web3 = new Web3(providerRPC.development); //Change to correct network
@@ -202,7 +202,7 @@ const incrementReceipt = await web3.eth.sendSignedTransaction(
202202
```js
203203
const web3Socket = new Web3(
204204
new Web3.providers.WebsocketProvider(
205-
"wss://kovan.infura.io/ws/v3/0aae8358bfe04803b8e75bb4755eaf07"
205+
"wss://goerli.infura.io/ws/v3/0aae8358bfe04803b8e75bb4755eaf07"
206206
)
207207
);
208208
incrementer = new web3Socket.eth.Contract(abi, createReceipt.contractAddress);
@@ -243,5 +243,5 @@ incrementTransaction = await web3.eth.accounts.signTransaction(
243243
代码参考文章如下
244244
https://docs.moonbeam.network/getting-started/local-node/deploy-contract/
245245

246-
Kovan 测试网无法使用 http 进行 event 监听,需要使用 web3socket, 可参考如下文章
246+
goerli 测试网无法使用 http 进行 event 监听,需要使用 web3socket, 可参考如下文章
247247
https://medium.com/blockcentric/listening-for-smart-contract-events-on-public-blockchains-fdb5a8ac8b9a

basic/02-web3js-transaction/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const privatekey = process.env.PRIVATE_KEY;
8686
```js
8787
// Provider
8888
const providerRPC = {
89-
development: "https://kovan.infura.io/v3/" + process.env.INFURA_ID,
89+
development: "https://goerli.infura.io/v3/" + process.env.INFURA_ID,
9090
moonbase: "https://rpc.testnet.moonbeam.network",
9191
};
9292
const web3 = new Web3(providerRPC.development); //Change to correct network
@@ -195,12 +195,12 @@ In the interfaces, you retrieve the corresponding internal information by trigge
195195
```js
196196
const web3Socket = new Web3(
197197
new Web3.providers.WebsocketProvider(
198-
'wss://kovan.infura.io/ws/v3/' + process.env.INFURA_ID
198+
'wss://goerli.infura.io/ws/v3/' + process.env.INFURA_ID
199199
));
200200
incrementer = new web3Socket.eth.Contract(abi, createReceipt.contractAddress);
201201

202202
```
203-
| kovan don't support http protocol to event listen, need to use websocket. More details , please refer to this [blog](https://medium.com/blockcentric/listening-for-smart-contract-events-on-public-blockchains-fdb5a8ac8b9a)
203+
| goerli don't support http protocol to event listen, need to use websocket. More details , please refer to this [blog](https://medium.com/blockcentric/listening-for-smart-contract-events-on-public-blockchains-fdb5a8ac8b9a)
204204

205205
#### Listen to Increment event only once
206206
```js
@@ -217,4 +217,4 @@ incrementer.events.Increment(() => {
217217

218218
# References
219219
- Code part: https://docs.moonbeam.network/getting-started/local-node/deploy-contract/
220-
- web3socket of Kovan: https://medium.com/blockcentric/listening-for-smart-contract-events-on-public-blockchains-fdb5a8ac8b9a
220+
- web3socket of Goerli: https://medium.com/blockcentric/listening-for-smart-contract-events-on-public-blockchains-fdb5a8ac8b9a

basic/02-web3js-transaction/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const privatekey = process.env.PRIVATE_KEY;
1010
*/
1111
// Provider
1212
const providerRPC = {
13-
development: 'https://kovan.infura.io/v3/' + process.env.INFURA_ID,
13+
development: 'https://goerli.infura.io/v3/' + process.env.INFURA_ID,
1414
moonbase: 'https://rpc.testnet.moonbeam.network',
1515
};
1616
const web3 = new Web3(providerRPC.development); //Change to correct network
@@ -152,11 +152,11 @@ const Trans = async () => {
152152
console.log('============================ 5. Listen to Events');
153153
console.log(' Listen to Increment Event only once && continuouslly');
154154

155-
// kovan don't support http protocol to event listen, need to use websocket
155+
// goerli don't support http protocol to event listen, need to use websocket
156156
// more details , please refer to https://medium.com/blockcentric/listening-for-smart-contract-events-on-public-blockchains-fdb5a8ac8b9a
157157
const web3Socket = new Web3(
158158
new Web3.providers.WebsocketProvider(
159-
'wss://kovan.infura.io/ws/v3/' + process.env.INFURA_ID
159+
'wss://goerli.infura.io/ws/v3/' + process.env.INFURA_ID
160160
)
161161
);
162162
incrementer = new web3Socket.eth.Contract(abi, createReceipt.contractAddress);

basic/03-web3js-erc20/README-cn.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@
119119

120120
4. 构造 web3 对象
121121
通过 web3 对象可以很方便的发送相应的交易到区块链网络, 同时获取区块链的处理结果.
122-
构造 web3 对象时, 主要需要传入一个参数, 就是对应的区块链网络, 包括 kovan, ropsten , rinkeby 等测试网络, 或是 mainnet 主网.
123-
这里我们使用 kovan 测试网络. 如果没有 kovan 网络的测试币, 可以切换到其他的测试网络.
122+
构造 web3 对象时, 主要需要传入一个参数, 就是对应的区块链网络, 包括 goerli 等测试网络, 或是 mainnet 主网.
123+
这里我们使用 goerli 测试网络. 如果没有 goerli 网络的测试币, 可以切换到其他的测试网络.
124124
同时需要注意的是, 这里我们通过 infura 向对应的区块链网络发送交易, 而 INFURA_ID 这个变量值也需要配置在 .env 文件中, 具体如何获取 infura_id, 可自行搜索查找相关文档
125125

126126
```js
127-
const web3 = new Web3(new Web3.providers.HttpProvider('https://kovan.infura.io/v3/' + process.env.INFURA_ID));
127+
const web3 = new Web3(new Web3.providers.HttpProvider('https://goerli.infura.io/v3/' + process.env.INFURA_ID));
128128
```
129129

130130
5. 获取账户地址

basic/03-web3js-erc20/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const receiver = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266';
113113
4. Build the `web3` object
114114

115115
```js
116-
const web3 = new Web3(new Web3.providers.HttpProvider('https://kovan.infura.io/v3/' + process.env.INFURA_ID));
116+
const web3 = new Web3(new Web3.providers.HttpProvider('https://goerli.infura.io/v3/' + process.env.INFURA_ID));
117117
```
118118
| Note: The `INFURA_ID` is the `PROJECT ID` of the `Infura` project you created in last [task](../01-web3js-deploy/README.md)
119119

basic/03-web3js-erc20/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const receiver = '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266';
1313
// Provider
1414
const web3 = new Web3(
1515
new Web3.providers.HttpProvider(
16-
'https://kovan.infura.io/v3/' + process.env.INFURA_ID
16+
'https://goerli.infura.io/v3/' + process.env.INFURA_ID
1717
)
1818
);
1919

basic/04-web3js-truffle/README-CN.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ truffle 开发框架提供了很多功能,简化了我们的开发、编译、
3636
3. truffle-config.js (之前是 truffle.js): Truffle 配置文件, 用来设置网络信息,和其他项目相关的设置。当我们使用内建的默认的 Truffle 命令时,这个文件留空也是可以的。
3737

3838
## 测试流程
39-
4039
1. 安装 truffle
4140
```bash
4241
npm install -g truffle
@@ -47,7 +46,12 @@ npm install -g truffle
4746
npm config set registry http://registry.npm.taobao.org
4847
```
4948

50-
2. 配置 .env
49+
2. 安装依赖
50+
```bash
51+
yarn install
52+
```
53+
54+
3. 配置 .env
5155

5256
```sh
5357
cp .env.example .env
@@ -57,15 +61,15 @@ npm config set registry http://registry.npm.taobao.org
5761
INFURA_ID=yyyyyyyy
5862
```
5963

60-
3. 测试合约
64+
4. 测试合约
6165
```bash
6266
truffle test
6367
```
6468

6569
这里,使用 "truffle test" 后,truffle 会启动内置的 test 网络,同时执行 测试 test 目录下的所有脚本,如果想单独测试某个脚本,可以
6670
执行 "truffle test ./test/simpletoken.js"
6771

68-
4. 编译合约
72+
5. 编译合约
6973
```bash
7074
truffle compile
7175
```
@@ -81,16 +85,16 @@ Writing artifacts to .\build\contracts
8185
5. 部署合约
8286

8387
在 truffle-config.js 里面,可以配置 truffle 使用的以太网络,其中就包括 truffle test 使用的 "test" 网络。
84-
这里,直接执行 truffle migrate 报没有找到 test 网络,因为 truffle 不会启动内置的 test 网络。所以这里我们使用 kovan 进行 truffle 合约部署
88+
这里,直接执行 truffle migrate 报没有找到 test 网络,因为 truffle 不会启动内置的 test 网络。所以这里我们使用 goerli 进行 truffle 合约部署
8589

8690
```bash
87-
truffle migrate --network kovan
91+
truffle migrate --network goerli
8892
```
8993

9094
当多次执行 truffle migrate 的时候,可能会出 "Network update to date", 然后不执行合约部署的情况,这个时候需要执行如下的 truffle 命令
9195

9296
```bash
93-
truffle migrate --network kovan --reset
97+
truffle migrate --network goerli --reset
9498
```
9599

96100
## 在 infura 测试合约
@@ -100,7 +104,7 @@ sol 的测试文件会报失败。所以,这里我们连接到 infura 进行
100104

101105

102106
```bash
103-
truffle test ./test/simpletoken.js --network kovan
107+
truffle test ./test/simpletoken.js --network goerli
104108
```
105109

106110
## 在本地测试合约

0 commit comments

Comments
 (0)