From 6b2ebd1ad64a055e07c724c1bbc15da4cdc5bfff Mon Sep 17 00:00:00 2001 From: Alex992Y Date: Mon, 18 Mar 2024 22:40:26 +0000 Subject: [PATCH] for Sepolia test --- basic/06-ethersjs-waffle/README-cn.md | 4 ++ basic/06-ethersjs-waffle/README.md | 4 ++ basic/06-ethersjs-waffle/index.js | 4 +- basic/07-hardhat/README-CN.md | 59 ++++++++++++------- basic/07-hardhat/README.md | 54 ++++++++++------- basic/07-hardhat/arguments_Greeter.js | 3 + basic/07-hardhat/arguments_SimpleToken.js | 6 ++ basic/07-hardhat/hardhat.config.js | 30 +++++----- basic/07-hardhat/scripts/deploy.js | 9 +++ basic/08-hardhat-graph/README-CN.md | 19 ++++-- basic/08-hardhat-graph/README.md | 14 +++-- basic/08-hardhat-graph/hardhat.config.js | 14 ++++- basic/08-hardhat-graph/package.json | 36 +++++++---- basic/09-hardhat-react/hardhat.config.js | 12 +--- basic/10-hardhat-ipfs-erc721/README-CN.md | 4 +- basic/10-hardhat-ipfs-erc721/README.md | 2 + .../10-hardhat-ipfs-erc721/hardhat.config.js | 20 +------ 17 files changed, 181 insertions(+), 113 deletions(-) create mode 100644 basic/07-hardhat/arguments_Greeter.js create mode 100644 basic/07-hardhat/arguments_SimpleToken.js diff --git a/basic/06-ethersjs-waffle/README-cn.md b/basic/06-ethersjs-waffle/README-cn.md index c9435072e..9ffc736f2 100644 --- a/basic/06-ethersjs-waffle/README-cn.md +++ b/basic/06-ethersjs-waffle/README-cn.md @@ -27,6 +27,8 @@ Waffle 详细使用方法可以参考 [Waffle 官网](https://ethereum-waffle.re ```bash yarn install + +#node 版本 v20.11.0 ``` - 2 编译合约 @@ -53,6 +55,8 @@ yarn test ```bash node index.js + +## index.js 第19行 let address = "xxxxxxx" 修改成自己地址 ``` ## 说明 在使用命yarn install命令,提示无法找到yarn命令时(比如在VMware上跑),可以尝试执行: diff --git a/basic/06-ethersjs-waffle/README.md b/basic/06-ethersjs-waffle/README.md index 4c62beff1..3a22791da 100644 --- a/basic/06-ethersjs-waffle/README.md +++ b/basic/06-ethersjs-waffle/README.md @@ -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 @@ -52,6 +54,8 @@ yarn test ```bash node index.js + +## index.js Line 19:let address = "xxxxxxx" change account to self ``` ## Note diff --git a/basic/06-ethersjs-waffle/index.js b/basic/06-ethersjs-waffle/index.js index 58cdf1a20..8f4ce8516 100644 --- a/basic/06-ethersjs-waffle/index.js +++ b/basic/06-ethersjs-waffle/index.js @@ -6,11 +6,11 @@ const { ethers } = require("ethers"); require("dotenv").config(); const privateKey = process.env.PRIVATE_KEY; -// const web3 = new Web3.providers.HttpProvider('https://kovan.infura.io/v3/0aae8358bfe04803b8e75bb4755eaf07'); +// const web3 = new Web3.providers.HttpProvider('https://sepolia.infura.io/v3/0aae8358bfe04803b8e75bb4755eaf07'); // let web3Provider = new ethers.providers.Web3Provider(web3) const web3Provider = new ethers.providers.InfuraProvider( - "goerli", + "sepolia", process.env.INFURA_ID ); diff --git a/basic/07-hardhat/README-CN.md b/basic/07-hardhat/README-CN.md index fa6ef42d2..6e6242a37 100644 --- a/basic/07-hardhat/README-CN.md +++ b/basic/07-hardhat/README-CN.md @@ -24,8 +24,7 @@ Hardhat Runner 是与 Hardhat 交互的 CLI 命令,是一个可扩展的任务 ## 项目结构和配置 hardhat ```sh -mkdir 07-hardhat // 创建项目文件夹 -cd 07-hardhat // 移动到项目文件夹下 +cd 07-hardhat // 移到Hardhat项目文件夹 npm install --save-dev hardhat // 安装hardhat npx hardhat // 创建hardhat项目 ``` @@ -42,17 +41,17 @@ npx hardhat // 创建hardhat项目 888 888 888 888 888 Y88b 888 888 888 888 888 Y88b. 888 888 "Y888888 888 "Y88888 888 888 "Y888888 "Y888 -Welcome to Hardhat v2.9.0 +👷 Welcome to Hardhat v2.21.0 👷‍ -? What do you want to do? ... -> Create a basic sample project - Create an advanced sample project - Create an advanced sample project that uses TypeScript +? What do you want to do? … +❯ Create a JavaScript project + Create a TypeScript project + Create a TypeScript project (with Viem) Create an empty hardhat.config.js Quit ``` -我们使用'Create a basic sample project'选项,创建一个基础项目,后面的两个选项直接敲回车选择默认值。 +我们使用'Create a JavaScript project'选项,创建一个基础项目,后面的两个选项直接敲回车选择默认值。 ### 项目结构 @@ -77,7 +76,7 @@ hardhat.config.js ```js require('@nomiclabs/hardhat-waffle'); require('dotenv').config(); - +require('@nomicfoundation/hardhat-verify'); module.exports = { networks: { // hardhat 内置测试网络(选填) @@ -87,10 +86,10 @@ module.exports = { }, // 你可以在这里配置任意网络 // goerli 测试网络 - goerli: { + sepolia: { // 请将 INFURA_ID 替换成你自己的 - // url: 'https://goerli.infura.io/v3/{INFURA_ID}', - url: 'https://goerli.infura.io/v3/' + process.env.INFURA_ID, //<---- 在.env文件中配置自己的INFURA_ID + // url: 'https://sepolia.infura.io/v3/{INFURA_ID}', + url: 'https://sepolia.infura.io/v3/' + process.env.INFURA_ID, //<---- 在.env文件中配置自己的INFURA_ID // 填写测试账户的私钥,可填写多个 accounts: [process.env.PRIVATE_KEY, ...] @@ -140,16 +139,20 @@ require('@nomiclabs/hardhat-waffle'); // hardhat waffle 插件 1. 安装 nodejs (略) + ```js + //Node 版本 v20.11.0 + ``` + 2. 安装项目依赖: ```sh - npm install --save-dev @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers ethers dotenv + npm install --save-dev @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers @nomicfoundation/hardhat-verify ethers dotenv ``` 或使用 yarn 安装(需要先安装 yarn 依赖) ```sh - yarn add -D hardhat-deploy-ethers ethers chai chai-ethers mocha @types/chai @types/mocha dotenv + yarn add -D hardhat-deploy-ethers ethers chai chai-ethers mocha @types/chai @nomicfoundation/hardhat-verify @types/mocha dotenv ``` 3. 配置私钥和网络: @@ -159,6 +162,7 @@ require('@nomiclabs/hardhat-waffle'); // hardhat waffle 插件 ```js PRIVATE_KEY = xxxxxxxxxxxxxxxx; // 替换为你的私钥 INFURA_ID = yyyyyyyy; // 替换为infura节点 + APIKEY=zzzzzz; //替换etherscan的apikey,下文有介绍 ``` ## usage @@ -179,6 +183,7 @@ npx hardhat compile ```sh npx hardhat test +#test网络使用本机网络,不需要指定 --network ``` 也可以指定运行某个特定测试文件 @@ -197,25 +202,35 @@ npx hardhat run ./scripts/deploy.js 指定运行的网络,例如在 goerli 测试网部署合约(请确保钱包地址在 goerli 测试网有足够的 gas 才能成功部署) ```sh -npx hardhat run ./scripts/deploy.js --network goerli +npx hardhat run ./scripts/deploy.js --network sepolia + +#请记住此处运行完之后返回的 “deploy address“,下面 verify 在sepolia网络验证时会用到 ``` ### verify -验证智能合约,这里以`goerli`举例。 +验证智能合约,这里以`sepolia`举例。 在 `hardhat.config.js` 添加配置: ```js  etherscan: { -   apiKey: "", +   apiKey: "",//用process.env.APIKEY 获取变量  } ``` +https://etherscan.io/myapikey 官网创建账号,登陆之后,My Account(自己创建的账号实际名称) -> API Keys 菜单中创建 + +确保 hardhat.config.js里配置 +require("@nomicfoundation/hardhat-verify"); +且已安装上述模块 npm install --save-dev @nomicfoundation/hardhat-verify + 运行脚本: ```shell -npx hardhat verify --network goerli <合约地址> +npx hardhat verify --contract "contracts/SimpleToken.sol:SimpleToken" --constructor-args ./arguments_SimpleToken.js --network sepolia <合约地址> + +#arguments_SimpleToken.js 中的数据为 第207行运行deplo.js脚本时,构造SimpleToken合约时,设置的参数 ``` ### task @@ -288,7 +303,7 @@ contract Greeter { } ``` -在运行测试文件时,可以看到打印出的日志: +在运行测试文件时(命令:npx hardhat test ./test/greeter.test.js),可以看到打印出的日志: ```sh Changing greeting from 'Hello, world!' to 'hello Dapp-Learning!' @@ -317,15 +332,15 @@ Changing greeting from 'Hello, world!' to 'hello Dapp-Learning!' npx hardhat run scripts/deploy.js --network ``` - 这里的 `network-name` 替换成你指定的网络名称,这里可以换成 `goerli`,对应配置文件中的网络名称。 + 这里的 `network-name` 替换成你指定的网络名称,这里可以换成 `sepolia`,对应配置文件中的网络名称。 4. 验证智能合约 ```bash - npx hardhat verify --network goerli + npx hardhat verify --contract "contracts/SimpleToken.sol:SimpleToken" --constructor-args ./arguments_SimpleToken.js --network ``` - `network-name` :你指定的网络名称,这里可以换成 `goerli`,对应配置文件中的网络名称。 + `network-name` :你指定的网络名称,这里可以换成 `sepolia`,对应配置文件中的网络名称。 `contract-address` :上一步部署的合约地址。 diff --git a/basic/07-hardhat/README.md b/basic/07-hardhat/README.md index 76656a2c2..18a2b2376 100644 --- a/basic/07-hardhat/README.md +++ b/basic/07-hardhat/README.md @@ -22,7 +22,6 @@ Before learning hardhat, you need to understand some Knowledge points as follows ## Project structure and configuration hardhat ```sh -mkdir 07-hardhat // create folder cd 07-hardhat // move to folder npm install --save-dev hardhat // install hardhat npx hardhat // initialize hardhat @@ -40,17 +39,17 @@ Finished in inputing `npx hardhat`, it will show in the terminal: 888 888 888 888 888 Y88b 888 888 888 888 888 Y88b. 888 888 "Y888888 888 "Y88888 888 888 "Y888888 "Y888 -Welcome to Hardhat v2.9.0 +👷 Welcome to Hardhat v2.21.0 👷‍ -? What do you want to do? ... -> Create a basic sample project - Create an advanced sample project - Create an advanced sample project that uses TypeScript +? What do you want to do? … +❯ Create a JavaScript project + Create a TypeScript project + Create a TypeScript project (with Viem) Create an empty hardhat.config.js Quit ``` -We select 'Create a basic sample project' options to initialize a basic project, click enter directly in the next 2 steps. +We select 'Create a JavaScript project' options to initialize a basic project, click enter directly in the next 2 steps. ### Project stucture @@ -85,10 +84,10 @@ module.exports = { }, // you could config arbitrary network // goerli testing network - goerli: { + sepolia: { // place INFURA_ID to yours - // url: 'https://goerli.infura.io/v3/{INFURA_ID}', - url: 'https://goerli.infura.io/v3/' + process.env.INFURA_ID, //<---- 在.env文件中配置自己的INFURA_ID + // url: 'https://sepolia.infura.io/v3/{INFURA_ID}', + url: 'https://sepolia.infura.io/v3/' + process.env.INFURA_ID, //<---- 在.env文件中配置自己的INFURA_ID // place multiple privateKeyX to yours accounts: [process.env.PRIVATE_KEY, ...] @@ -138,17 +137,17 @@ require('@nomiclabs/hardhat-waffle'); // hardhat waffle plugin ### Install dependencies 1. install nodejs (ignore) - + # Node version v20.11.0 2. install project dependencies: ```sh - npm install --save-dev @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers ethers dotenv + npm install --save-dev @nomiclabs/hardhat-waffle ethereum-waffle chai @nomicfoundation/hardhat-verify @nomiclabs/hardhat-ethers ethers dotenv ``` or use yarn to intall (yarn installed firstly) ```sh - yarn add -D hardhat-deploy-ethers ethers chai chai-ethers mocha @types/chai @types/mocha dotenv + yarn add -D hardhat-deploy-ethers ethers chai chai-ethers mocha @types/chai @nomicfoundation/hardhat-verify @types/mocha dotenv ``` 3. config private key and network: @@ -158,6 +157,7 @@ require('@nomiclabs/hardhat-waffle'); // hardhat waffle plugin ```js PRIVATE_KEY = xxxxxxxxxxxxxxxx; // place your private key INFURA_ID = yyyyyyyy; // place infura node + APIKEY=zzzzzz; //replace etherscan apikey,will introduce below ``` ## Usage @@ -178,6 +178,7 @@ Run the command, hardhat will compile all test files in directory of `tests`, th ```sh npx hardhat test +#test network no need assign --network ``` you could also specify some test files to run it @@ -197,7 +198,10 @@ npx hardhat run ./scripts/deploy.js Run the specified network, such as the contract deployed on goerli test network(make sure that the wallet could pay the gas) ```sh -npx hardhat run ./scripts/deploy.js --network goerli +npx hardhat run ./scripts/deploy.js --network sepolia + + +#Please remember the "deploy address" returned after running here, which will be used by verify in Sepolia network verification below ``` ### Verify @@ -207,15 +211,25 @@ Verify the smart contract, here is an example of `goerli`. Add the following configuration to `hardhat.config.js`: ```js - etherscan: { -   apiKey: "", +  etherscan: { +   apiKey: "", //Use process.env.APIKEY Get Variables  } ``` +https://etherscan.io/myapikey Create an account on the official website. After logging in, go to My Account (the actual name of the account you created) ->API Key + +Ensure configuration in hardhat.config.js + +Require ("@nomofoundation/hardhat-verify"); + +And the above module npm install --savedev @nomicfoundation/hardhat-verify has been installed + Run script: ```shell -npx hardhat verify --network goerli +npx hardhat verify --contract "contracts/SimpleToken.sol:SimpleToken" --constructor-args ./arguments_SimpleToken.js --network sepolia + +##The data in arguments SimpleToken.js are the parameters set during the construction of the SimpleToken contract when running the deploy. js script on line 207 ``` ### Task @@ -316,15 +330,15 @@ Changing greeting from 'Hello, world!' to 'hello Dapp-Learning!' npx hardhat run scripts/deploy.js --network ``` - `network-name` should be replaced with your networks, `goerli` is a choice which exists in the config file. + `network-name` should be replaced with your networks, `sepolia` is a choice which exists in the config file. 4. Verify smart contract ```bash - npx hardhat verify --network goerli + npx hardhat verify --contract "contracts/SimpleToken.sol:SimpleToken" --constructor-args ./arguments_SimpleToken.js --network ``` - `network-name` : the name of the network you specify, here you can replace it with `goerli`, which corresponds to the network name in the configuration file. + `network-name` : the name of the network you specify, here you can replace it with `sepolia`, which corresponds to the network name in the configuration file. `contract-address` : The address of the contract deployed in the previous step. diff --git a/basic/07-hardhat/arguments_Greeter.js b/basic/07-hardhat/arguments_Greeter.js new file mode 100644 index 000000000..e82137891 --- /dev/null +++ b/basic/07-hardhat/arguments_Greeter.js @@ -0,0 +1,3 @@ +module.exports = [ + "Hello, world", + ]; \ No newline at end of file diff --git a/basic/07-hardhat/arguments_SimpleToken.js b/basic/07-hardhat/arguments_SimpleToken.js new file mode 100644 index 000000000..2ec024f65 --- /dev/null +++ b/basic/07-hardhat/arguments_SimpleToken.js @@ -0,0 +1,6 @@ +module.exports = [ + 'SimpleToken', + 'SimpleToken', + 18, + 10000000000, + ]; \ No newline at end of file diff --git a/basic/07-hardhat/hardhat.config.js b/basic/07-hardhat/hardhat.config.js index 17da05d6f..0f2d1b9ea 100644 --- a/basic/07-hardhat/hardhat.config.js +++ b/basic/07-hardhat/hardhat.config.js @@ -1,5 +1,7 @@ require('@nomiclabs/hardhat-waffle'); require('dotenv').config(); +require('@nomicfoundation/hardhat-verify'); + // This is a sample Hardhat task. To learn how to create your own go to // https://hardhat.org/guides/create-task.html @@ -12,6 +14,8 @@ task('accounts', 'Prints the list of accounts', async () => { }); function mnemonic() { + //can config 3 PRIVATE_KEY + //return process.env.PRIVATE_KEY,process.env.PRIVATE_KEY1,process.env.PRIVATE_KEY2; return process.env.PRIVATE_KEY; } @@ -34,25 +38,23 @@ 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, //<---- CONFIG YOUR INFURA ID IN .ENV! (or it won't work) + sepolia: { + 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()], }, - ropsten: { - url: 'https://ropsten.infura.io/v3/' + process.env.INFURA_ID, //<---- CONFIG YOUR INFURA ID IN .ENV! (or it won't work) - accounts: [mnemonic()], - }, - arbitest: { - url: 'https://arbitrum-rinkeby.infura.io/v3/' + process.env.INFURA_ID, //<---- CONFIG YOUR INFURA ID IN .ENV! (or it won't work) - accounts: [mnemonic()], - }, - matic: { - url: 'https://polygon-mainnet.infura.io/v3/' + process.env.PROJECT_ID, //<---- CONFIG YOUR INFURA ID IN .ENV! (or it won't work) - accounts: [mnemonic()] - }, }, + etherscan: { + apiKey: { + sepolia: process.env.APIKEY + } , + }, + sourcify: { + // Disabled by default + // Doesn't need an API key + enabled: true + } }; diff --git a/basic/07-hardhat/scripts/deploy.js b/basic/07-hardhat/scripts/deploy.js index 61c32f4dd..e867e8e80 100644 --- a/basic/07-hardhat/scripts/deploy.js +++ b/basic/07-hardhat/scripts/deploy.js @@ -15,6 +15,15 @@ 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 & SimpleToken both need, not delete + console.log('deploy address:', token.address); diff --git a/basic/08-hardhat-graph/README-CN.md b/basic/08-hardhat-graph/README-CN.md index da445f2bb..ed79dc0b0 100644 --- a/basic/08-hardhat-graph/README-CN.md +++ b/basic/08-hardhat-graph/README-CN.md @@ -25,6 +25,8 @@ TheGraph 中定义如何为数据建立索引,称为 Subgraph,它包含三 ```bash yarn install + + #node版本 v20.11.0 ``` 2. 配置私钥 @@ -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 ``` 输出信息类似如下: @@ -81,10 +83,13 @@ TheGraph 中定义如何为数据建立索引,称为 Subgraph,它包含三 graph init --product hosted-service / ``` - - 在 "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. 修改定义模式 @@ -206,6 +211,8 @@ TheGraph 中定义如何为数据建立索引,称为 Subgraph,它包含三 ```bash graph auth --studio + + #注意需要按截图所示点击copy key按钮,并替换 , 不要直接copy 官网右侧的代码,因为key不全 ``` 若使用 Hosted Service,则初始化命令如下: @@ -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 ``` @@ -295,7 +302,7 @@ 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,修改内容如下: @@ -303,7 +310,7 @@ docker-compose -f docker-compose.yml up -d dataSources: - kind: ethereum/contract name: SimpleToken - network: goerli + network: sepolia ``` diff --git a/basic/08-hardhat-graph/README.md b/basic/08-hardhat-graph/README.md index ea3fc20f8..f96bad190 100644 --- a/basic/08-hardhat-graph/README.md +++ b/basic/08-hardhat-graph/README.md @@ -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 @@ -34,7 +36,7 @@ TheGraph defines that how to create data index, which is called Subgraph, includ 3. Deploy contracts(testing graph's simple contracts) ```bash - npx hardhat run ./scripts/deploy.js --network goerli + npx hardhat run ./scripts/deploy.js --network sepolia ``` print info as follows: @@ -78,11 +80,13 @@ TheGraph defines that how to create data index, which is called Subgraph, includ ```bash graph init --product hosted-service / ``` - + - Protocol Select Ethereum - choose "Subgraph name" and "Direction to create the subgraph", then enter it. - - choose goerli in Ethereum network + - choose sepolia in Ethereum network - input your contract address generated when the contract was deployed in Step 3 in "Contract address" - When it came to "fetch ABI from Etherscan", it will fail, then show "ABI file (path)" which prompt that input the path of abi, we should input the path of SimpleToken.json(`./abis/SimpleToken.json`) + . If task 07-hardhat has been successfully executed and ethyscan has been configured in hardhat.config.js, the execution here will pass through + -After the "fetch Start Block" execution fails, enter n for retry, "Start Block", and "Contract Name" default to carriage return. "Add another contract?" Enter n - If yarn install fails (network error), you can enter in the new directory and install npm dependencies manually. 7. Modify the mode of defining @@ -292,7 +296,7 @@ docker-compose -f docker-compose.yml up -d Enter the directory of subgraph to run the command - Because the command was executed in the previous step: `npx hardhat run ./scripts/deploy.js --network goerli` + Because the command was executed in the previous step: `npx hardhat run ./scripts/deploy.js --network sepolia` subgraph.yml need to be changed as follows: @@ -300,7 +304,7 @@ docker-compose -f docker-compose.yml up -d dataSources: - kind: ethereum/contract name: SimpleToken - network: goerli + network: sepolia ``` diff --git a/basic/08-hardhat-graph/hardhat.config.js b/basic/08-hardhat-graph/hardhat.config.js index 35e03596f..c8f2d47f1 100644 --- a/basic/08-hardhat-graph/hardhat.config.js +++ b/basic/08-hardhat-graph/hardhat.config.js @@ -20,8 +20,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: [PRIVATE_KEY], }, mainnet: { @@ -32,7 +32,17 @@ module.exports = { url: 'https://ropsten.infura.io/v3/' + process.env.INFURA_ID, //<---- YOUR INFURA ID! (or it won't work) accounts: [PRIVATE_KEY], }, + }, + etherscan: { + apiKey: { + sepolia: process.env.APIKEY + } , }, + sourcify: { + // Disabled by default + // Doesn't need an API key + enabled: true + } }; // This is a sample Hardhat task. To learn how to create your own go to diff --git a/basic/08-hardhat-graph/package.json b/basic/08-hardhat-graph/package.json index d4219c5fa..f662d84bf 100644 --- a/basic/08-hardhat-graph/package.json +++ b/basic/08-hardhat-graph/package.json @@ -1,20 +1,30 @@ { - "name": "hardhat-project", - "devDependencies": { - "@graphprotocol/graph-cli": "0.20.0", - "@nomiclabs/hardhat-ethers": "^2.0.2", - "@nomiclabs/hardhat-waffle": "^2.0.1", - "chai": "^4.3.4", - "ethereum-waffle": "^3.3.0", - "ethers": "^5.1.4", - "hardhat": "^2.2.1" + "name": "08-hardhat-graph", + "version": "1.0.0", + "description": "[中文](./README-CN.md) / English", + "main": "hardhat.config.js", + "directories": { + "test": "test" }, "scripts": { - "chain": "hardhat node", - "deploy": "npx hardhat run ./scripts/deploy.js" + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@nomicfoundation/hardhat-verify": "^2.0.4", + "@nomiclabs/hardhat-ethers": "^2.2.3", + "@nomiclabs/hardhat-waffle": "^2.0.6", + "@openzeppelin/contracts": "^4.9.6", + "chai": "^5.1.0", + "dotenv": "^16.4.5", + "ethereum-waffle": "^4.0.10", + "ethers": "^5.7.2", + "hardhat": "^2.21.0" }, "dependencies": { - "@openzeppelin/contracts": "^4.4.2", - "dotenv": "^10.0.0" + "dotenv": "^16.4.5", + "@openzeppelin/contracts": "^4.4.2" } } diff --git a/basic/09-hardhat-react/hardhat.config.js b/basic/09-hardhat-react/hardhat.config.js index aa0dba758..8913395f9 100644 --- a/basic/09-hardhat-react/hardhat.config.js +++ b/basic/09-hardhat-react/hardhat.config.js @@ -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()], - }, }, }; diff --git a/basic/10-hardhat-ipfs-erc721/README-CN.md b/basic/10-hardhat-ipfs-erc721/README-CN.md index bb5ba930f..7416ac78f 100644 --- a/basic/10-hardhat-ipfs-erc721/README-CN.md +++ b/basic/10-hardhat-ipfs-erc721/README-CN.md @@ -92,6 +92,8 @@ ipfs daemon ```bash yarn install 或者 npm install + + #Node 版本: v20.11.0 ``` 2. 配置私钥和网络: @@ -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 diff --git a/basic/10-hardhat-ipfs-erc721/README.md b/basic/10-hardhat-ipfs-erc721/README.md index 0476a858e..79bd1d0f3 100644 --- a/basic/10-hardhat-ipfs-erc721/README.md +++ b/basic/10-hardhat-ipfs-erc721/README.md @@ -92,6 +92,8 @@ ipfs daemon ```bash yarn install or npm install + + #Node 版本: v20.11.0 ``` 2. Configure private key and network diff --git a/basic/10-hardhat-ipfs-erc721/hardhat.config.js b/basic/10-hardhat-ipfs-erc721/hardhat.config.js index 1b0d65be2..4d3756c75 100644 --- a/basic/10-hardhat-ipfs-erc721/hardhat.config.js +++ b/basic/10-hardhat-ipfs-erc721/hardhat.config.js @@ -33,29 +33,13 @@ 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: { 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()], - }, - matic: { - url: "https://polygon-mainnet.infura.io/v3/" + process.env.INFURA_ID, - accounts: [ - mnemonic() - ] - }, - matic_mumbai: { - url: "https://polygon-mumbai.infura.io/v3/" + process.env.INFURA_ID, - accounts: [ - mnemonic() - ] - }, }, };