Home > front end >  "npx hardhat accounts" not available in Hardhat latest version 2.9.9
"npx hardhat accounts" not available in Hardhat latest version 2.9.9

Time:01-14

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?

CodePudding user response:

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

CodePudding user response:

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);
  }
});

CodePudding user response:

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!

CodePudding user response:

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

  • Related