“npx Hardhat 帐户”在 Hardhat 最新版本 2.9.9 中不可用

Uma*_*air 12 ethereum hardhat

我已经安装了最新版本的安全帽。它安装得很好。

设置安全帽并安装所有必需的软件包后,当我运行时:

npx hardhat accounts
Run Code Online (Sandbox Code Playgroud)

它给出了一个错误:

Error HH303: Unrecognized task accounts
Run Code Online (Sandbox Code Playgroud)

似乎“帐户”任务已在最新版本的安全帽中删除。我现在的问题是获取安全帽生成的钱包帐户列表?

小智 18

我2022年8月16日也有同样的情况。

为了获取可用帐户,我使用该npx hardhat node命令。

我执行的命令序列是:

$ npx hardhat --version
2.10.1

$ npx hardhat accounts
Error HH303: Unrecognized task accounts
For more info go to https://hardhat.org/HH303 or run Hardhat with --show-stack-traces

$ npx hardhat node
Started HTTP and WebSocket JSON-RPC server at http://127.0.0.1:8545/

Accounts
========

WARNING: These accounts, and their private keys, are publicly known.
Any funds sent to them on Mainnet or any other live network WILL BE LOST.

Account #0: 0xf39Fd6e51a...ffFb92266 (10000 ETH)
Private Key: 0xac0974bec39a1...478cbed5efcae784d7bf4f2ff80

Account #1: 0x70997970C51812...b50e0d17dc79C8 (10000 ETH)
Private Key: 0x59c6995e998f97a5a...9dc9e86dae88c7a8412f4603b6b78690d
.
.
.
Run Code Online (Sandbox Code Playgroud)


Nan*_*Yaw 14

这是因为最新版本中不包含帐户任务。在Hardhat.config.js中添加以下内容

task("accounts", "Prints the list of accounts", async () => {
  const accounts = await ethers.getSigners();

  for (const account of accounts) {
    console.log(account.address);
  }
});
Run Code Online (Sandbox Code Playgroud)