- Ubuntu 20.04.2
- hardhat 2.12.2
- node 16.13.1
- yarn 1.22.17
- visual studio code
- goerli测试网络provider 使用的是infura (https://app.infura.io/ 可以创建)
- yarn
- 打开文件 hardhat.config.ts, 替换xxxxxxxxxx
- url: 'https://goerli.infura.io/v3/xxxxxxxxxx', //<---- 你的 INFURA 项目 ID! (https://app.infura.io/ 可以创建)
- accounts: ['xxxxxxxx'], //<---- 密钥! (metamask 读取)
- yarn hardhat compile
- 打开本地EVM yarn hardhat node
- 本地部署 yarn hardhat deploy --network localhost
- 提案 yarn hardhat run scripts/propose.ts --network localhost
- 投票 yarn hardhat run scripts/vote.ts --network localhost
- 投票成功后排队任务 yarn hardhat run scripts/queue.ts --network localhost
- 执行该排队任务 yarn hardhat run scripts/execute.ts --network localhost
note: 打开terminal 使用hardhat console查询投票状态变化
输入 yarn hardhat console –network localhost(/goerli)
输入 const governor = await ethers.getContract("GovernorContract")
输入 await governor.state(“proposalID”) (proposalID 从文件 proposals.json 读取)
得到投票情况,对照结尾对照表表查询状态
- goerli测试网络部署 yarn hardhat deploy --network goerli
- 提案 yarn hardhat run scripts/propose.ts --network goerli
- 投票 yarn hardhat run scripts/vote.ts --network goerli
- 投票成功后排队任务 yarn hardhat run scripts/queue.ts --network goerli
- 执行该排队任务 yarn hardhat run scripts/execute.ts --network goerli
note: 打开terminal 使用hardhat console查询投票状态变化
输入 yarn hardhat console –network localhost(/goerli)
输入 const governor = await ethers.getContract("GovernorContract")
输入 await governor.state(“proposalID”) (proposalID 从文件 proposals.json 读取)
得到投票情况,对照结尾对照表表查询状态
enum ProposalState { Pending, //0 Active, //1 Canceled, //2 Defeated, //3 Succeeded, //4 Queued, //5 Expired, //6 Executed //7、 }