Skip to content

Commit

Permalink
for sepolia test
Browse files Browse the repository at this point in the history
for sepolia test
  • Loading branch information
Alex992Y committed Mar 13, 2024
1 parent dc22116 commit 4e56e1a
Show file tree
Hide file tree
Showing 21 changed files with 55 additions and 48 deletions.
2 changes: 1 addition & 1 deletion basic/06-ethersjs-waffle/README-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Waffle 详细使用方法可以参考 [Waffle 官网](https://ethereum-waffle.re
```bash
yarn install

# node 版本 v20.11.0
#node 版本 v20.11.0
```
- 2 编译合约

Expand Down
2 changes: 2 additions & 0 deletions basic/06-ethersjs-waffle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ You can refer to the offical website of Waffle width the detailed usage(https://

```bash
yarn install

#node version v20.11.0
```

- 2 compile contracts
Expand Down
2 changes: 1 addition & 1 deletion basic/07-hardhat/README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ require('@nomiclabs/hardhat-waffle'); // hardhat waffle 插件
1. 安装 nodejs (略)
```js
// Node 版本 v20.11.0
//Node 版本 v20.11.0
```
2. 安装项目依赖:
Expand Down
2 changes: 1 addition & 1 deletion basic/07-hardhat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ require('@nomiclabs/hardhat-waffle'); // hardhat waffle plugin
### Install dependencies
1. install nodejs (ignore)
// Node version v20.11.0
# Node version v20.11.0
2. install project dependencies:
```sh
Expand Down
2 changes: 1 addition & 1 deletion basic/07-hardhat/arguments_Greeter.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = [
"Hello, world",
];
];
2 changes: 1 addition & 1 deletion basic/07-hardhat/arguments_SimpleToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module.exports = [
'SimpleToken',
18,
10000000000,
];
];
2 changes: 0 additions & 2 deletions basic/07-hardhat/contracts/Greeter.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
//import "hardhat/console.sol";
contract Greeter {
string greeting;

Expand All @@ -14,7 +13,6 @@ contract Greeter {
}

function setGreeting(string memory _greeting) public {
// console.log("Changing greeting from '%s' to '%s'", greeting, _greeting);
greeting = _greeting;
}
}
2 changes: 0 additions & 2 deletions basic/07-hardhat/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ module.exports = {
url: 'https://sepolia.infura.io/v3/' + process.env.INFURA_ID, //<---- CONFIG YOUR INFURA ID IN .ENV! (or it won't work)
accounts: [mnemonic()],
},
/*
mainnet: {
url: 'https://mainnet.infura.io/v3/' + process.env.INFURA_ID, //<---- CONFIG YOUR INFURA ID IN .ENV! (or it won't work)
accounts: [mnemonic()],
},
*/
},
etherscan: {
apiKey: {
Expand Down
9 changes: 5 additions & 4 deletions basic/07-hardhat/scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ async function main() {
const Token = await ethers.getContractFactory('SimpleToken');
const token = await Token.deploy('SimpleToken', 'SimpleToken', 18, 10000000000);

// ---- for Greeter verify
//const Greeter = await ethers.getContractFactory("Greeter");
//const token = await Greeter.deploy("Hello, world");
// await token.deployed();
/** ---- for Greeter verify
const Greeter = await ethers.getContractFactory("Greeter");
const token = await Greeter.deploy("Hello, world");
await token.deployed();
*/


//--- for Greeter & SimpleToken both need, not delete
Expand Down
25 changes: 16 additions & 9 deletions basic/08-hardhat-graph/README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## 流程概述

-Goerli 部署一个合约,并调用触发事件。
-sepolia 部署一个合约,并调用触发事件。
- 创建定义数据索引的 Subgraph。
- 部署 Subgraph 到 TheGraph,实现数据索引。
- 在前端 DApp 中查询索引数据。
Expand All @@ -25,6 +25,8 @@ TheGraph 中定义如何为数据建立索引,称为 Subgraph,它包含三

```bash
yarn install

#node版本 v20.11.0
```

2. 配置私钥
Expand All @@ -35,7 +37,7 @@ TheGraph 中定义如何为数据建立索引,称为 Subgraph,它包含三
3. 部署合约(用于测试 graph 的简单合约)

```bash
npx hardhat run ./scripts/deploy.js --network goerli
npx hardhat run ./scripts/deploy.js --network sepolia
```

输出信息类似如下:
Expand All @@ -59,7 +61,7 @@ TheGraph 中定义如何为数据建立索引,称为 Subgraph,它包含三

输入你的项目名称(例如 TEST01),以下称之为 `<SUBGRAPH_NAME>`,点击 continue 按钮,之后会跳转到 subgraph 的项目主页

注:最新版的 Graph CLI 仅支持在 mainnet 和 goerli 上部署,若要在其他网络上使用,需要使用 Github 账户登录后在 Hosted Service 上创建和部署
注:最新版的 Graph CLI 仅支持在 mainnet 和 sepolia 上部署,若要在其他网络上使用,需要使用 Github 账户登录后在 Hosted Service 上创建和部署

5. 开发和部署 subgraph

Expand All @@ -73,18 +75,21 @@ TheGraph 中定义如何为数据建立索引,称为 Subgraph,它包含三

```bash
graph init --studio <SUBGRAPH_NAME>

```

若使用 Hosted Service,则初始化命令如下:

```bash
graph init --product hosted-service <GITHUB_USER>/<SUBGRAPH NAME>
```

- 在 "Subgraph name" 和 "Directory to create the subgraph" 直接回车即可
- Ethereum network 这里选择 goerli
- Protocol 选择ethereum
- 在 "Subgraph slug" 和 "Directory to create the subgraph" 直接回车即可
- Ethereum network 这里选择 sepolia
- "Contract address" 这里输入在步骤 3 中部署合约时生成的合约地址
- 上面执行到 "fetch ABI from Etherscan" 时会报执行失败,然后出现 "ABI file (path)" 字样,提示输入本机中 abi 的文件路径,这里我们输入 SimpleToken.json 所在的路径即可(`./abis/SimpleToken.json`)
。如果已经成功执行 07-hardhat , 同时在hardhat.config.js 里配置了ethescan,此处执行会通过
-"fetch Start Block"执行失败后,retry输入n,“Start Block”,“Contract Name”默认回车。 “Add another contract?” 输入n
- 如果 yarn install 失败(例如网络错误),可以进入新生成的项目目录,手动安装 npm 依赖

7. 修改定义模式
Expand Down Expand Up @@ -206,6 +211,8 @@ TheGraph 中定义如何为数据建立索引,称为 Subgraph,它包含三

```bash
graph auth --studio <DEPLOY KEY>

#注意需要按截图所示点击copy key按钮,并替换<DEPLOY KEY> , 不要直接copy 官网右侧的代码,因为key不全
```

若使用 Hosted Service,则初始化命令如下:
Expand Down Expand Up @@ -278,7 +285,7 @@ graph-node:
postgres_db: graph-node
ipfs: 'ipfs:5001'
ethereum: 'mainnet:http://127.0.0.1:8545' #此处的mainnet需要和subgraph.yml里network对应上
# ethereum: 'dev:https://goerli.infura.io/v3/INFURA_ID' # 也可以连测试网络
# ethereum: 'dev:https://sepolia.infura.io/v3/INFURA_ID' # 也可以连测试网络
RUST_LOG: info
```

Expand All @@ -295,15 +302,15 @@ docker-compose -f docker-compose.yml up -d
3. 编译 subgraph
进入 subgraph 的本地目录运行下列命令

由于在前一步骤执行过命令 npx hardhat run ./scripts/deploy.js --network goerli
由于在前一步骤执行过命令 npx hardhat run ./scripts/deploy.js --network sepolia

因此,此处修改 subgraph.yaml,修改内容如下:

```bash
dataSources:
- kind: ethereum/contract
name: SimpleToken
network: goerli
network: sepolia
```

Expand Down
2 changes: 2 additions & 0 deletions basic/08-hardhat-graph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ TheGraph defines that how to create data index, which is called Subgraph, includ

```bash
yarn install

#node version v20.11.0
```

2. Configure the private key
Expand Down
4 changes: 4 additions & 0 deletions basic/08-hardhat-graph/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ module.exports = {
url: 'https://sepolia.infura.io/v3/' + process.env.INFURA_ID, //<---- YOUR INFURA ID! (or it won't work)
accounts: [PRIVATE_KEY],
},
goerli: {
url: 'https://goerli.infura.io/v3/' + process.env.INFURA_ID, //<---- YOUR INFURA ID! (or it won't work)
accounts: [PRIVATE_KEY],
},
mainnet: {
url: 'https://mainnet.infura.io/v3/' + process.env.INFURA_ID, //<---- YOUR INFURA ID! (or it won't work)
accounts: [PRIVATE_KEY],
Expand Down
16 changes: 6 additions & 10 deletions basic/08-hardhat-graph/sepoliatest/subgraph.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
specVersion: 1.0.0
specVersion: 0.0.4
indexerHints:
prune: auto
schema:
file: ./schema.graphql
dataSources:
- kind: ethereum
- kind: ethereum/contract
name: SimpleToken
network: sepolia
network: mainnet
source:
address: "0x4cC83Bee49A8D80eBaC1C50D147B9027440423d0"
abi: SimpleToken
startBlock: 0
mapping:
kind: ethereum/events
apiVersion: 0.0.7
apiVersion: 0.0.6
language: wasm/assemblyscript
entities:
- CloseStream
- Deposit
- ExecuteTransaction
- OpenStream
- Owner
- Withdraw
- TransferEntity
- ApprovalEntity
abis:
- name: SimpleToken
file: ./abis/SimpleToken.json
Expand Down
2 changes: 1 addition & 1 deletion basic/09-hardhat-react/README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Dapp 开发中很重要的部分便是前端展示,本样例代码使用 hardh
2. 部署合约

```sh
npx hardhat run scripts/deploy.js --network goerli
npx hardhat run scripts/deploy.js --network sepolia
```

3. 启动 react
Expand Down
2 changes: 2 additions & 0 deletions basic/09-hardhat-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Put your private key in .env for easy access, formatted with "PRIVATE_KEY=xxxx".

```sh
npm install

#Node version v20.11.0
```

2. Deploy contracts
Expand Down
2 changes: 1 addition & 1 deletion basic/09-hardhat-react/frontend/src/components/Dapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export class Dapp extends React.Component {
}

this.setState({
networkError: 'Please connect Metamask to goerli',
networkError: 'Please connect Metamask to sepolia',
})

return false
Expand Down
12 changes: 2 additions & 10 deletions basic/09-hardhat-react/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,13 @@ module.exports = {
(you can put in a mnemonic here to set the deployer locally)
*/
},
kovan: {
url: 'https://kovan.infura.io/v3/' + process.env.INFURA_ID, //<---- YOUR INFURA ID! (or it won't work)
sepolia: {
url: 'https://sepolia.infura.io/v3/' + process.env.INFURA_ID, //<---- YOUR INFURA ID! (or it won't work)
accounts: [mnemonic()],
},
mainnet: {
url: 'https://mainnet.infura.io/v3/' + process.env.INFURA_ID, //<---- YOUR INFURA ID! (or it won't work)
accounts: [mnemonic()],
},
ropsten: {
url: 'https://ropsten.infura.io/v3/' + process.env.INFURA_ID, //<---- YOUR INFURA ID! (or it won't work)
accounts: [mnemonic()],
},
goerli: {
url: 'https://goerli.infura.io/v3/' + process.env.INFURA_ID, //<---- YOUR INFURA ID! (or it won't work)
accounts: [mnemonic()],
},
},
};
4 changes: 3 additions & 1 deletion basic/10-hardhat-ipfs-erc721/README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ ipfs daemon

```bash
yarn install 或者 npm install

#Node 版本: v20.11.0
```

2. 配置私钥和网络:
Expand All @@ -118,7 +120,7 @@ ipfs daemon
3. 执行如下命令

```angular2html
npx hardhat run scripts/deploy-ipfs.js --network goerli
npx hardhat run scripts/deploy-ipfs.js --network sepolia
```

运行结束后,在 console 输出的日志中,最后一行打印出了你上传文件独有的 hash
Expand Down
4 changes: 3 additions & 1 deletion basic/10-hardhat-ipfs-erc721/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ ipfs daemon

```bash
yarn install or npm install

#Node 版本: v20.11.0
```

2. Configure private key and network
Expand All @@ -118,7 +120,7 @@ ipfs daemon
3. Run the following command

```angular2html
npx hardhat run scripts/deploy-ipfs.js --network goerli
npx hardhat run scripts/deploy-ipfs.js --network sepolia
```

After running, the last line of the console log prints the hash unique to the file you uploaded
Expand Down
1 change: 1 addition & 0 deletions basic/10-hardhat-ipfs-erc721/contracts/MYERC721.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "./ERC721PresetMinterPauserAutoId.sol";
Expand Down
4 changes: 2 additions & 2 deletions basic/10-hardhat-ipfs-erc721/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ module.exports = {
(you can put in a mnemonic here to set the deployer locally)
*/
},
goerli: {
url: 'https://goerli.infura.io/v3/' + process.env.INFURA_ID, //<---- YOUR INFURA ID! (or it won't work)
sepolia: {
url: 'https://sepolia.infura.io/v3/' + process.env.INFURA_ID, //<---- YOUR INFURA ID! (or it won't work)
accounts: [mnemonic()],
},
mainnet: {
Expand Down

0 comments on commit 4e56e1a

Please sign in to comment.