10

I have installed the latest version of hardhat. It installed fine.

After setting hardhat up and installing all the required packages, when I run:

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. My question is now to get the list of wallet accounts that hardhat generates?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Umair
  • 313
  • 3
  • 10
  • Could not reproduce your issue - the `accounts` task is working correctly on my end after installing `hardhat@2.9.9` and initializing the basic project. Can you check your `hardhat.config.js` whether it contains a line starting `task("accounts"`? – Petr Hejda Jul 12 '22 at 07:37

4 Answers4

16

I have the same situation on 2022-08-16.

To get the available accounts, I use the npx hardhat node command.

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
.
.
.
Carlos J. Ramirez
  • 1,049
  • 7
  • 9
13

This is because the accounts tasks is not included in the latest release. Add the following in your 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);
  }
});
Nana Yaw
  • 129
  • 3
1

I use yarn hardhat node to display a list of hardhat accounts on the terminal

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 02 '22 at 07:36
0

im not sure but I managed to fix this by migrating waffle to Beth chai masters as required and rm from config the waffle and add the chai masters after that could not get accounts els how than "npx hardhat node" looks like accounts are displayed when launching the node if it can help!

Adyl ITTO
  • 1
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Coder Gautam YT Jul 20 '22 at 19:03