# Getting started with Hardhat 3

Description: Get started using Hardhat 3

Note: This document was authored using MDX

  Source: https://github.com/NomicFoundation/hardhat-website/tree/main/src/content/docs/docs/getting-started.mdx

  Components used in this page:
    - <Run cmd="..."/>: Runs a command in the terminal with npm/pnpm/yarn.
    - <RunRemote>: Runs a command in the terminal with npx/pnpm dlx/yarn dlx.
    - <FileTree>: Displays file/folder structure from an unordered list. Supports `**bold**` for highlighting, `...` for placeholders, and comments after filenames.
    - :::tip: A helpful tip callout block. Supports custom title `:::tip[Title]` and icon `:::tip{icon="name"}` syntax.

import { FileTree } from "@astrojs/starlight/components";
import RunRemote from "@hh/RunRemote.astro";
import Run from "@hh/Run.astro";

:::tip

Hardhat 3 is production-ready and you can migrate today. We'll keep it in beta status as we work on missing features and stabilize it.

:::

Hardhat is a flexible and extensible development environment for Ethereum software. It helps you write, test, debug, and deploy your smart contracts with ease, whether you're building a simple prototype or a complex production system.

This guide will walk you through installing our recommended setup, but since most of Hardhat's functionality comes from plugins, you're free to customize it or choose a completely different path.

## Prerequisites

- [Node.js](https://nodejs.org/) v22 or later
- A package manager like [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), or [yarn](https://yarnpkg.com/) (we strongly recommend pnpm)
- A text editor (we recommend [VS Code](https://code.visualstudio.com/) with our [Official Hardhat extension](https://marketplace.visualstudio.com/items?itemName=NomicFoundation.hardhat-solidity))

## Installation

First, create a new directory for your project:

```sh
mkdir hardhat-example
cd hardhat-example
```

Once that's done, initialize your Hardhat project by running:

<RunRemote command="hardhat --init" />

This command will prompt you with a few configuration options. You can accept the default answers to quickly create a working setup.

Using the defaults will initialize the project in the current directory and automatically install all required dependencies.

After the setup completes, you'll have a fully working Hardhat 3 project. To verify everything's set up correctly, run:

<Run command="hardhat --help" />

To try out a complete test run of your project, run:

<Run command="hardhat test" />

## Project structure

The Hardhat project initialization from the previous section creates the following file structure:

{/* prettier-ignore */}
<FileTree>
- hardhat-example
  - package.json
  - hardhat.config.ts
  - contracts
    - Counter.sol
    - Counter.t.sol
  - test
    - Counter.ts
  - ignition
    - modules
      - Counter.ts
  - scripts
    - send-op-tx.ts
</FileTree>

Here's what each file and directory does:

- `package.json`: Your npm package file where Hardhat and its plugins are installed.

- `hardhat.config.ts`: Your project's main configuration file. It defines the Solidity compiler version, network configurations, plugins, and tasks.

- `contracts`: Contains your Solidity contracts. You can also include Solidity test files here using the `.t.sol` extension.

- `test`: Contains TypeScript and Solidity tests. Solidity test files in this folder can use either `.sol` or `.t.sol`.

- `ignition`: Contains [Hardhat Ignition](/ignition) deployment modules that describe how to deploy your contracts. Learn more [here](/docs/guides/deployment/using-ignition).

- `scripts`: Contains custom scripts that automate parts of your workflow. Scripts have full access to Hardhat's runtime and can use plugins, connect to networks, and deploy contracts.

You can learn more about what's included in your sample project by reading the [`hardhat-toolbox-viem` documentation](/docs/plugins/hardhat-toolbox-viem), which is the recommended setup you're using.

## Learn more

To learn more about Hardhat, we recommend reading the [tutorial](/docs/tutorial) next.

Once you've finished the tutorial, or if you prefer smaller focused guides, check out:

- [What's new in Hardhat 3](/docs/hardhat3/whats-new)
- [Writing Solidity tests](/docs/guides/testing/using-solidity)
- [Using Viem with Hardhat to test in TypeScript](/docs/guides/testing/using-viem)
- [Deploying contracts](/docs/guides/deployment)
- [Configuring the compiler](/docs/guides/writing-contracts/configuring-the-compiler)
- [Getting gas statistics of your test runs](/docs/guides/testing/gas-statistics)
- [Computing the code coverage of your tests](/docs/guides/testing/code-coverage)

Join our [Hardhat 3](https://hardhat.org/hardhat3-beta-telegram-group) Telegram group to share feedback and stay updated on new releases.
