Lesson 6: accounts task not available on Hardhat #825
-
Hii, I am following the course and in Lesson 6 when seeing the Available Tasks of hardhat when typing:
I do not receive This is what I get when trying to get the accounts:
Thank you very much! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 9 replies
-
@SebasAran16 It will not come by default, you have to create an account task and then require it inside the hardhat config file then it will appear with the above command. |
Beta Was this translation helpful? Give feedback.
-
@SebasAran16 you are most likely using the latest version, if you are, then don't worry as the task |
Beta Was this translation helpful? Give feedback.
-
@SebasAran16 Did you try running |
Beta Was this translation helpful? Give feedback.
-
@SebasAran16 The problem is that they removed it as a pre-defined sample task in the new Hardhat update, I have still listed it below if you want to use that sample task:
Hope this helped! |
Beta Was this translation helpful? Give feedback.
-
Hi @SebasAran16, depending on your experience, this may / may not be helpful. Think of your terminal as a file manager; typing program names like yarn or npm or cd executes (runs) the program. The hardhat program - is built to look for the hardhat.config.js file in your working directory (programming location). Now, think:
So:
task is a function that hardhat.config.js will look for, it accepts 3 arguments:
require("@nomicfoundation/hardhat-toolbox");
// add code from @krakxn -->
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.9",
}; After adding the code, you will be able to execute |
Beta Was this translation helpful? Give feedback.
@SebasAran16 The problem is that they removed it as a pre-defined sample task in the new Hardhat update, I have still listed it below if you want to use that sample task:
Hope this helped!