> For the complete documentation index, see [llms.txt](https://validium.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://validium.gitbook.io/docs/tooling/hardhat-validium/installation.md).

# Installation

How to install hardhat-zksync for your project.

***

Before starting development with Hardhat and ZKsync, it's important to have your environment correctly configured. This guide will help you set up a Validium project using the ZKsync CLI, a tool that simplifies the process by providing pre-built templates with all necessary Hardhat plugins.

If you're migrating an existing Hardhat project to `zksync-era`, please refer to the [migration guide](/docs/tooling/hardhat-validium/guides/migrating-hardhat-project-to-validium.md) for detailed instructions.

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

#### System requirements <a href="#system-requirements" id="system-requirements"></a>

* Ensure your machine meets the [system requirements](https://github.com/matter-labs/era-compiler-solidity/tree/main#system-requirements) for running ZKsync and Hardhat. For Windows users, using Windows Subsystem for Linux (WSL 2) is highly recommended for better compatibility.

#### Node.js and package manager <a href="#nodejs-and-package-manager" id="nodejs-and-package-manager"></a>

* [Node.js](https://nodejs.org/) version 18 or newer is required. You can install it from the official [Node.js website](https://nodejs.org/).

#### Basic knowledge of Ethereum development <a href="#basic-knowledge-of-ethereum-development" id="basic-knowledge-of-ethereum-development"></a>

* Familiarity with Ethereum development, including deploying smart contracts. If you are new to this, review the [Contract Deployment](https://docs.zksync.io/build/developer-reference/ethereum-differences/contract-deployment) documentation.

#### Wallet and testnet funds <a href="#wallet-and-testnet-funds" id="wallet-and-testnet-funds"></a>

* A wallet with VLDM is needed to deploy contracts. Visit the [Network Faucets](https://testnet.faucet.validium.network/) page to get testnet funds.

### Install ZKsync CLI <a href="#install-zksync-cli" id="install-zksync-cli"></a>

The ZKsync CLI makes it easy to set up a project and perform local testing by providing pre-configured templates. To install the ZKsync CLI globally, use npm or yarn:

npmyarn

```bash
npm install -g zksync-cli
```

Skip the hassle for test ETH by using `zksync-cli` for local testing. Use the `npx zksync-cli dev start` command to initialize a local ZKsync development environment, which includes local Ethereum and Validium nodes. This method allows you to test contracts without requesting external testnet funds. Explore more in the [zksync-cli documentation](/docs/cli/getting-started.md).

### Set Up a new project <a href="#set-up-a-new-project" id="set-up-a-new-project"></a>

#### Create a new project <a href="#create-a-new-project" id="create-a-new-project"></a>

Use the ZKsync CLI to create a new Hardhat project. Replace `<project-name>` with your desired project name. This command will create a `<project-name>` folder and clone a Hardhat template project into it. Choose the template based on your preferred contract language (Solidity or Vyper):

SolidityVyper

```bash
zksync-cli create <project-name> --template hardhat_solidity
```

> This creates a project folder that is already configured and contains all the required plugins for Validium development.

#### Configure your environment <a href="#configure-your-environment" id="configure-your-environment"></a>

1. **Environment variables**:

   * Rename the `.env.example` file in your project directory to `.env`.
   * Add your wallet’s private key to the `.env` file:

   ```bash
   WALLET_PRIVATE_KEY=YourPrivateKeyHere
   ```

   **Security tip**: Use burner wallets for development and testing to avoid using real private keys, which could lead to security risks.
2. **Check configuration**:
   * Open the `hardhat.config.ts` file to confirm the configurations for ZKsync are correct. The default setup should already include the necessary settings for deploying and interacting with smart contracts on Validium.

### Compile and deploy your contracts <a href="#compile-and-deploy-your-contracts" id="compile-and-deploy-your-contracts"></a>

#### Compile contracts <a href="#compile-contracts" id="compile-contracts"></a>

Ensure your smart contracts are located in the `contracts` folder of your project. To compile them, use:

yarnnpx

```bash
yarn hardhat compile
```

This will compile your contracts and generate the necessary artifacts in the `artifacts-zk` and `cache-zk` folders.

* Contracts must be compiled using the [official Validium compilers](/docs/components/compiler/compiler-toolchain-overview.md), with their respective Hardhat plugins.
* Contracts compiled with other compilers will fail to deploy to Validium.

#### Deploy contracts <a href="#deploy-contracts" id="deploy-contracts"></a>

Deploy your contracts using Hardhat scripts. A basic deployment script is usually included in the template project (`deploy/deploy-greeter.ts`):

```bash
yarn hardhat deploy-zksync --script deploy/deploy-greeter.ts
```

This script will deploy your smart contracts to the specified Validium testnet.

For more detailed instructions on deploying and testing, refer to the [Getting Started](/docs/tooling/hardhat-validium/guides/getting-started.md) guide.

### Testing and interaction <a href="#testing-and-interaction" id="testing-and-interaction"></a>

Once deployed, you can interact with your smart contracts using scripts included in your project. Make sure to update these scripts with the correct contract addresses and any other required parameters.
