Setting up a Hardhat Project

To setup a project that uses Hardhat for Ethereum contract development, do the following:

  1. Install a recent version of Node.js. We need the npm and npx commands for the rest of this chapter.
  2. Create a new directory and enter it.
    mkdir hello-world
    cd hello-world
    
  3. Initialize a new Node.js project.
    npm init -y
    
    The directory should contain a single file called package.json.
  4. Install Hardhat by running the following command in the hello-world directory.
    npm install --save-dev hardhat
    
    The package.json file will now have a hardhat section under devDependencies.
  5. Create a Hardhat project by running the following command. Choose the Create an empty hardhat.config.js option.
    npx hardhat
    
    The directory will have a file called hardhat.config.js with the following contents.
    /** @type import('hardhat/config').HardhatUserConfig */
    module.exports = {
        solidity: "0.8.17",
    };
    
    The number 0.8.17 specifies the version of the Solidity compiler.