简体   繁体   English

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

[英]"npx hardhat accounts" not available in Hardhat latest version 2.9.9

I have installed the latest version of hardhat.我已经安装了最新版本的 hardhat。 It installed fine.它安装得很好。

After setting hardhat up and installing all the required packages, when I run:设置 hardhat 并安装所有必需的软件包后,当我运行时:

npx hardhat accounts

It gives an error:它给出了一个错误:

Error HH303: Unrecognized task accounts

It seems like 'account' task has been removed in the latest version of hardhat.似乎在最新版本的 hardhat 中删除了“帐户”任务。 My question is now to get the list of wallet accounts that hardhat generates?我现在的问题是获取 hardhat 生成的钱包帐户列表?

我不确定,但我设法通过根据需要将 waffle 迁移到 Beth chai masters 并从配置 waffle 并添加 chai masters 来解决此问题,之后无法获取帐户,否则“npx hardhat node”看起来像帐户在启动时显示节点是否可以提供帮助!

I have the same situation on 2022-08-16.我在 2022-08-16 也遇到了同样的情况。

To get the available accounts, I use the npx hardhat node command.要获取可用帐户,我使用npx hardhat node命令。

The command sequence I performed was:我执行的命令序列是:

$ 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
.
.
.

This is because the accounts tasks is not included in the latest release.这是因为帐户任务未包含在最新版本中。 Add the following in your hardhat.config.js在您的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); } });

I use yarn hardhat node to display a list of hardhat accounts on the terminal我使用 yarn hardhat node 在终端上显示 hardhat 帐户列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM