Updated 28 June 2024

<aside> <img src="/icons/star_lightgray.svg" alt="/icons/star_lightgray.svg" width="40px" /> NEW: Contract verification on the ZKcandy Block Explorer is now working. Please update your hardhat.config.js file with the new one from this tutorial and Configure Your Environment with the new updated commands.

</aside>

There are multiple ways to deploy contracts to the ZKcandy Testnet. For this tutorial, we will be using @matterlabs/hardhat-zksync-deploy - part of the ZKsync plugin set for the Hardhat development environment.

This plugin provides utilities for deploying smart contracts on ZKsync Era and by extension, ZKcandy with artifacts built by the @matterlabs/hardhat-zksync-solc or @matterlabs/hardhat-zksync-vyper plugins.

<aside> <img src="/icons/book_lightgray.svg" alt="/icons/book_lightgray.svg" width="40px" /> This documentation is written with reference the the official zkSync Hardhat Plugin documentation.

</aside>

Table of Contents

As this is a long document that covers setting up a development environment and subsequently the deployment of a contract to the ZKcandy Sepolia Testnet, this list will help you navigate through the steps

  1. Prerequisites
  2. Local Testing
  3. Initialisation
  4. Configuring Your Environment
  5. Compiling & Preparing Your Contract

Prerequisites

<aside> <img src="/icons/warning_lightgray.svg" alt="/icons/warning_lightgray.svg" width="40px" /> This method of deployment requires the use of your wallet private key in your project’s environment variables. For testing, do not use a wallet with mainnet funds on any blockchain, not just ZKcandy or ZKsync Era. For the purposes of this document, this secret will be stored in a .env file. It is imperative that this file is never committed to any version control system.

</aside>

Local Testing