Skip to content

Hardhat 3 projects

A Hardhat Project is an npm package that uses Hardhat. In other words, it’s a directory with a package.json file, and a Hardhat config file either in the same directory or one of its subdirectories.

The Hardhat project root directory is the directory containing the package.json file, matching the behavior of npm.

For example, in this case:

  • Directorydirectory
    • package.json
    • Directoryconfig/
      • hardhat.config.ts

directory is the project root, not config.

We recommend keeping both the package.json and the hardhat.config.ts in the root of the project, and installing hardhat there.

  • Directoryroot
    • package.json Has hardhat installed
    • hardhat.config.ts

The package.json of the Hardhat project doesn’t need to install Hardhat directly. The only requirement is that your config needs to be able to import it. This can be helpful for integration tests of plugins and custom setups.

For example, in this case:

  • Directorydirectory
    • package.json Has hardhat installed
    • hardhat.config.ts
    • Directorytests
      • Directoryexample-project
        • package.json Doesn’t have hardhat installed
        • hardhat.config.ts

Both directory and example-project will be Hardhat projects, despite hardhat only being installed in directory.

If you’re using a monorepo, each package can have multiple projects, as explained above. However, we recommend using the Recommended structure in each of your packages.