Setting Up a Hardhat Development Environment

quickstart beginner

A step-by-step guide to configuring a Hardhat project to compile, test, and deploy smart contracts on the Maroo network.

Maroo is EVM-compatible, so a stock Hardhat project works without Maroo-specific patches. This guide walks through creating a new Hardhat project pointed at Maroo Testnet.

Prerequisites

  • Node.js 20.19 or newer — Hardhat 3 declares no engines field, but its dependency tree requires it
  • A funded testnet account — see the faucet on the testnet access page

1. Initialize a Hardhat Project

Create a project directory and install Hardhat. Three things differ from most Hardhat guides you will find online, because Maroo builds against Hardhat 3: the project must be ESM, hardhat-toolbox must not be installed, and the scaffold command is npx hardhat --init.
mkdir maroo-project && cd maroo-project
npm init -y

# Hardhat 3 is ESM-only. Without this the first compile fails with
# "Hardhat only supports ESM projects."
npm pkg set type="module"

# Pin the major version. Do NOT add @nomicfoundation/hardhat-toolbox:
# its current release supports neither Hardhat 2 nor 3, and Maroo's own
# contracts build without it.
npm install --save-dev hardhat@^3.1.10

# Scaffold. Bare `npx hardhat` errors on Hardhat 3 — use --init.
npx hardhat --init
Note: When prompted by npx hardhat, choose 'Create a TypeScript project' for the best development experience.

2. Configure `hardhat.config.ts`

Open hardhat.config.ts and add the network entry. Two Hardhat 3 details bite here: the config type is a type-only import, and every network needs an explicit type. Pull your private key from .env (do not commit it).
import type { HardhatUserConfig } from "hardhat/config";
import * as dotenv from "dotenv";
dotenv.config();

const PRIVATE_KEY = process.env.PRIVATE_KEY || "";

const config: HardhatUserConfig = {
  // Maroo's own contracts compile with 0.8.28 — match it so bytecode and
  // behaviour line up with the deployed precompiles.
  solidity: "0.8.28",
  networks: {
    maroo_testnet: {
      type: "http",          // required by Hardhat 3; omitting it fails config validation
      url: "https://rpc-testnet.maroo.io",
      chainId: 450815,       // Mainnet: 815
      accounts: PRIVATE_KEY ? [PRIVATE_KEY] : [],
    },
  },
};

export default config;
Warning: Never commit private keys to Git. Use environment variables (.env file). For testnet funds, request from the faucet instead of generating a key from a validator.

3. Compile and Deploy

With the configuration in place, compile and deploy. Hardhat's sample project ships a Lock.sol contract and a deployment script.
# Compile the contracts
npx hardhat compile

# Deploy to Maroo Testnet
npx hardhat run scripts/deploy.ts --network maroo_testnet

Conclusion

Your Hardhat project is now wired to Maroo Testnet. The same project structure, plugins, and tests you'd use on Ethereum mainnet apply unchanged.
ESC
Type to search