Integrations / Development Environment

Quai Hardhat Integration

Quai's zone chains run an EVM, so the Hardhat workflow Solidity teams already know — compile, test, script, deploy — carries over directly. Point your config at chain ID 9, swap Ethers for the quais SDK in deploy scripts, and ship.

Works with
Hardhat 2.x · Solidity ≤ 0.8.20
Mainnet
Chain ID 9 · rpc.quai.network/cyprus1
Testnet
Orchard · Chain ID 15000
Maintained example
dominant-strategies/hardhat-example
01

How Hardhat fits Quai

Quai Network is a hierarchy of EVM-compatible chains secured by a single pool of proof-of-work. Transactions execute on zone chains like Cyprus-1, which run an EVM derived from go-ethereum — so contracts written for Ethereum compile and run on Quai without modification. Hardhat handles compilation, local testing, and deployment scripting exactly as it does on any EVM chain.

Two things differ from Ethereum. First, Quai nodes expose a quai_ JSON-RPC namespace instead of eth_, so deployment scripts use the quais SDK — a maintained fork of Ethers v6 with a near-identical API — rather than stock Ethers. Second, Quai's address space is sharded: an address prefix determines which zone it lives on, and contract deployment automatically grinds addresses to land in your target zone (CREATE handles this for you; CREATE2 salts must resolve to a valid zone address).

The dominant-strategies/hardhat-example repository wires all of this together — network config, environment handling, and quais-based deploy scripts for both vanilla Solidity and cross-chain SolidityX projects.

02

Set up Hardhat for Quai

The fastest path is the maintained example repo. The steps below show what it configures, so you can also adapt an existing Hardhat project.

  1. 1

    Clone the example and install

    The repo contains a Solidity/ project for standard contracts and a SolidityX/ project for cross-chain contracts.

    terminalbash
    git clone https://github.com/dominant-strategies/hardhat-example.git
    cd hardhat-example/Solidity
    npm install
  2. 2

    Configure your environment

    Set the RPC endpoint, chain ID, and a deployer private key in the shared .env file. Use chain ID 9 for mainnet or 15000 for the Orchard testnet — testnet QUAI is free from the faucet at orchard.faucet.quai.network.

    .envbash
    RPC_URL="https://rpc.quai.network"
    CHAIN_ID="9"
    CYPRUS1_PK="0x..." # deployer key for the Cyprus-1 zone
  3. 3

    Point hardhat.config.js at a zone

    Each Quai zone is configured as a Hardhat network. Cyprus-1 is the primary zone live on mainnet today; the hierarchy is built to expand to nine zones across the Cyprus, Paxos, and Hydra regions.

    hardhat.config.jsjavascript
    require("@nomicfoundation/hardhat-toolbox");
    require("@quai/hardhat-deploy-metadata");
    const dotenv = require("dotenv");
    dotenv.config({ path: "../.env" });
    
    module.exports = {
      defaultNetwork: "cyprus1",
      networks: {
        cyprus1: {
          url: process.env.RPC_URL,
          accounts: [process.env.CYPRUS1_PK],
          chainId: Number(process.env.CHAIN_ID),
        },
      },
      solidity: {
        version: "0.8.20",
        settings: {
          optimizer: { enabled: true, runs: 1000 },
        },
      },
    };
  4. 4

    Deploy with a quais script

    Deploy scripts construct a provider and wallet from your Hardhat network config using quais instead of Ethers — the API is nearly identical.

    terminalbash
    npx hardhat run scripts/deployERC20.js --network cyprus1
  5. 5

    Verify on Quaiscan

    The @quai/hardhat-deploy-metadata plugin pushes contract metadata to IPFS at deploy time, which Quaiscan uses for source verification at quaiscan.io/contract-verification.

03

What teams use it for

  • Token launches

    ERC-20 and ERC-721 contracts deploy unchanged. The example repo ships both as ready-to-deploy templates with quais deployment scripts.

  • Protocol testing

    Run your unit and integration suites against the in-process Hardhat network before deploying — standard EVM semantics mean tests behave the same.

  • Cross-chain contracts with SolidityX

    The quai-hardhat-plugin adds the SolidityX compiler, enabling QRC-20X and QRC-721X contracts that move trustlessly between zones.

  • CI/CD pipelines

    Hardhat tasks script cleanly into CI: compile and test on every commit, deploy to Orchard testnet on merge, promote to mainnet on release.

04

Deploy an ERC-20 to Cyprus-1

A complete Hardhat deploy script using the quais SDK. If you've written an Ethers v6 deploy script, this is the same shape — provider, wallet, contract factory.

scripts/deployERC20.jsjavascript
const quais = require("quais");
const ERC20 = require("../artifacts/contracts/ERC20.sol/ERC20.json");

async function main() {
  // Provider + wallet from the Hardhat network config
  const provider = new quais.JsonRpcProvider(hre.network.config.url, undefined, {
    usePathing: true,
  });
  const wallet = new quais.Wallet(hre.network.config.accounts[0], provider);

  // Deploy exactly as you would with Ethers v6
  const factory = new quais.ContractFactory(ERC20.abi, ERC20.bytecode, wallet);
  const token = await factory.deploy("MyToken", "MTK", quais.parseQuai("1000000"));

  await token.waitForDeployment();
  console.log("ERC-20 deployed to:", await token.getAddress());
}

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

Frequently asked questions

Does standard Hardhat work with Quai Network?

Yes — compilation, the local Hardhat network, and your test suite work unchanged because Quai zones are EVM-compatible. The one substitution is in deployment scripts: Quai nodes expose a quai_ JSON-RPC namespace rather than eth_, so scripts use the quais SDK (an Ethers v6 fork with a near-identical API) instead of stock Ethers.

Which Solidity versions does Quai support?

Quai supports Solidity versions up to 0.8.20. Set your compiler version to 0.8.20 or lower in hardhat.config.js and your existing contracts compile as-is.

How do I deploy to a Quai testnet first?

Point your network config at the Orchard testnet — RPC https://orchard.rpc.quai.network/cyprus1 with chain ID 15000 — and fund your deployer from the faucet at orchard.faucet.quai.network. Contracts can then be promoted to mainnet (chain ID 9) with no code changes.

What is SolidityX and when do I need it?

SolidityX is a modified Solidity compiler for contracts that operate across multiple Quai zones, such as QRC-20X and QRC-721X cross-chain tokens. You only need it for multi-zone applications — single-zone contracts use standard Solidity. The quai-hardhat-plugin integrates the SolidityX compiler into your Hardhat build.

Do I need to change my existing contracts to deploy on Quai?

No. Contracts targeting a single zone deploy without modification. The only caveat is CREATE2: because Quai addresses encode their zone in the prefix, your salt must produce an address valid for the target zone, whereas plain CREATE deployments grind a valid address automatically.

Ship your first contract on Quai

Clone the example, fund a testnet wallet from the faucet, and deploy to Orchard in minutes.