◻️Deploying to ZONA with Hardhat

Hardhat is one of the most popular development environments for Ethereum. Since ZONA is EVM-compatible, you can use Hardhat to compile, test, and deploy your smart contracts to ZONA Testnet or Mainnet with minimal configuration changes.


✅ Prerequisites

Make sure you have:

  • Node.js installed (v14+)

  • A wallet with ZONA testnet tokens

  • MetaMask or a private key ready

  • RPC/Chain ID details (once available)


1. 📦 Create a Hardhat Project

If you haven’t already, initialize a new Hardhat project:

mkdir zona-hardhat && cd zona-hardhat
npm init -y
npm install --save-dev hardhat
npx hardhat

Choose “Create a basic sample project” when prompted.


2. 🧱 Install Dependencies

For deploying and interacting with contracts:

npm install --save-dev @nomicfoundation/hardhat-toolbox dotenv

Create a .env file:

PRIVATE_KEY=your_private_key_without_0x

3. ⚙️ Configure ZONA Network

In your hardhat.config.js file, add the ZONA network:

jrequire("@nomicfoundation/hardhat-toolbox");
require("dotenv").config();

module.exports = {
  solidity: "0.8.20",
  networks: {
    zonaTestnet: {
      url: "https://rpc-testnet.zonaprotocol.org", // Replace with actual RPC
      chainId: 9999,                                // Replace with actual Chain ID
      accounts: [`0x${process.env.PRIVATE_KEY}`]
    }
  }
};

Replace the RPC URL and chain ID once ZONA Testnet details are finalized.


4. ✍️ Write Your Contract

In contracts/, create ZonaToken.sol:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract ZonaToken is ERC20 {
    constructor(uint256 initialSupply) ERC20("ZonaToken", "ZONA") {
        _mint(msg.sender, initialSupply);
    }
}

5. 📜 Create a Deployment Script

In scripts/deploy.js:

async function main() {
  const ZonaToken = await ethers.getContractFactory("ZonaToken");
  const token = await ZonaToken.deploy(ethers.utils.parseEther("1000000"));
  await token.deployed();
  console.log(`ZonaToken deployed to: ${token.address}`);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

6. 🚀 Deploy to ZONA Testnet

Run:

npx hardhat run scripts/deploy.js --network zonaTestnet

If successful, you'll see:

ZonaToken deployed to: 0xYourContractAddress

✅ What’s Next?

  • Verify your contract on ZONA Explorer (Coming Soon)

  • Interact with your contract via CLI, Web3.js, or front-end

  • Share testnet contract with your community


You're now building on ZONA fast, scalable, and developer-first.

Last updated