Validium Docs
  • Overview
  • Connect to Validium
  • Start Coding 🚀
    • Quickstart
      • Overview
      • Deploy using Validium CLI
      • Deploy using Quickstart Repository
      • Deploy your first contract
      • Create an ERC20 token
  • Tooling
    • Block Explorers
    • Hardhat-Validium
      • Overview
      • Installation
      • Guides
        • Getting started
        • Migrating Hardhat project to Validium
        • Compiling non-inlinable libraries
      • Plugins
        • hardhat-zksync
        • hardhat-zksync-solc
        • hardhat-zksync-vyper
        • hardhat-zksync-deploy
        • hardhat-zksync-upgradable
        • hardhat-zksync-verify
        • hardhat-zksync-verify-vyper
        • hardhat-zksync-ethers
        • hardhat-zksync-node
        • Hardhat Community Plugins
    • Foundary
      • Overview
      • Installation
      • Getting Started
      • Migration Guide
        • Overview
        • Compilation
        • Deployment
        • Testing
  • Test and Debug
    • Getting Started
    • Docker L1 - L2 Nodes
    • In-Memory Node
    • Continuous Integration
    • Hardhat
    • Foundry
  • API Reference
    • Overview
    • Conventions
    • ZKs JSON-RPC API
    • Debug JSON-RPC API
    • Ethereum JSON-RPC API
    • PubSub JSON-RPC API
  • Concepts
    • Transaction Lifecycle
    • Blocks and Batches
    • Validium Network Fee Mechanism
    • Finality
    • System Upgrades
    • ZK Chains
    • Data Availability
      • Overview
      • Recreating L2 state from L1 pubdata
      • Validiums
    • Account Abstraction
    • L1 <-> L2 Communication
  • Components
    • Overview
    • Smart & System Contracts
      • Smart Contracts
      • System Contracts
    • Shared Bridges
    • Sequencer / Server
    • Validium Network EVM
      • Overview
      • Bootloader
      • Precompiles
      • Virtual Machine Specification
        • ZKsync Virtual Machine primer
        • VM Formal Specification
    • Prover
      • Overview
      • ZK Terminology
      • Running the Prover
      • Circuits
        • Overview
        • Circuit Testing
        • CodeDecommitter
        • DemuxLogQueue
        • ECRecover
        • KeccakRoundFunction
        • L1MessagesHasher
        • LogSorter
        • Main VM
        • RAMPermutation
        • Sha256RoundFunction
        • StorageApplication
        • Sorting and Deduplicating
          • Overview
          • SortDecommitments
          • StorageSorter
          • LogSorter
      • Boojum Gadgets
      • Boojum Function - `check_if_satisfied`
    • Compiler
      • Compiler Toolchain Overview
        • Compiler Toolchain Overview
        • Solidity Compiler
        • Vyper Compiler
        • LLVM Framework
      • Specification
        • Overview
        • Code Separation
        • System Contracts
        • Exception Handling
        • EVM Legacy Assembly Translator
        • Instructions
          • Instruction Reference
          • EVM
            • Native EVM Instructions
            • Arithmetic
            • Bitwise
            • Block
            • Call
            • Create
            • Environment
            • Logging
            • Logical
            • Memory
            • Return
            • Sha3
            • Stack
          • Extensions
            • Overview
            • Validium Network Extension Simulation (call)
            • Validium Network Extension Simulation (verbatim)
          • EVM Legacy Assembly
          • Yul
        • EraVM Binary Layout
    • Fee Withdrawer
    • Portal - Wallet + Bridge
    • Block Explorer
    • Transaction filtering
Powered by GitBook
On this page
  • Prerequisites
  • Install ZKsync CLI
  • Set Up a new project
  • Compile and deploy your contracts
  • Testing and interaction
  1. Tooling
  2. Hardhat-Validium

Installation

How to install hardhat-zksync for your project.

PreviousOverviewNextGuides

Last updated 7 months ago


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 for detailed instructions.

Prerequisites

System requirements

  • Ensure your machine meets the 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

  • version 18 or newer is required. You can install it from the official .

Basic knowledge of Ethereum development

  • Familiarity with Ethereum development, including deploying smart contracts. If you are new to this, review the documentation.

Wallet and testnet funds

  • A wallet with VLDM is needed to deploy contracts. Visit the page to get testnet funds.

Install ZKsync CLI

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

npm install -g zksync-cli

Set Up a new project

Create a new project

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

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

  1. Environment variables:

    • Rename the .env.example file in your project directory to .env.

    • Add your wallet’s private key to the .env file:

    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

Compile contracts

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

yarnnpx

yarn hardhat compile

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

  • Contracts compiled with other compilers will fail to deploy to Validium.

Deploy contracts

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

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

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

Testing and interaction

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.

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 .

Contracts must be compiled using the , with their respective Hardhat plugins.

For more detailed instructions on deploying and testing, refer to the guide.

migration guide
system requirements
Node.js
Node.js website
Contract Deployment
Network Faucets
zksync-cli documentation
official Validium compilers
Getting Started