Setting up a Hardhat Project
To setup a project that uses Hardhat for Ethereum contract development, do the following:
- Install a recent version of Node.js. We need the
npmandnpxcommands for the rest of this chapter. - Create a new directory and enter it.
mkdir hello-world cd hello-world - Initialize a new Node.js project.
The directory should contain a single file callednpm init -ypackage.json. - Install Hardhat by running the following command in the
hello-worlddirectory.
Thenpm install --save-dev hardhatpackage.jsonfile will now have ahardhatsection underdevDependencies. - Create a Hardhat project by running the following command. Choose the Create an empty hardhat.config.js option.
The directory will have a file callednpx hardhathardhat.config.jswith the following contents.
The number/** @type import('hardhat/config').HardhatUserConfig */ module.exports = { solidity: "0.8.17", };0.8.17specifies the version of the Solidity compiler.