Skip to content

Repository files navigation

Sample Hardhat3 Project (node:test and viem)

This project showcases a Hardhat3 project using the native Node.js test runner (node:test) and the viem library for Monad Testnet interactions.

To learn more about Hardhat3, please visit the Getting Started guide. For support, see Hardhat's current Getting help guide, or open an issue to report a bug.

Project Overview

This example project includes:

  • A simple Hardhat configuration file.
  • Foundry-compatible Solidity unit tests.
  • TypeScript integration tests using node:test, the Node.js native test runner, and viem.
  • Monad Testnet and Mainnet network configuration.

Setup

Install the dependencies:

npm install

Local compilation and tests do not require a private key. Before deploying to Testnet or Mainnet, set the PRIVATE_KEY configuration variable. Before verifying a contract, also set ETHERSCAN_API_KEY.

Store the variables in the Hardhat keystore:

npx hardhat keystore set PRIVATE_KEY
npx hardhat keystore set ETHERSCAN_API_KEY

Alternatively, copy .env.example to .env and fill in the values. The configuration loads this file through dotenv.

cp .env.example .env

Never commit .env or expose a funded account's private key.

Usage

Running Tests

To run all the tests in the project, execute the following command:

npx hardhat test

You can also selectively run the Solidity or node:test tests:

npx hardhat test solidity
npx hardhat test nodejs

Deployment

This project includes an example Ignition module to deploy the contract. You can deploy this module to a locally simulated chain, Monad Testnet, or Monad Mainnet.

Deploy to Local Chain

Local deployment does not require configuration variables:

npx hardhat ignition deploy ignition/modules/Counter.ts

Deploy to Monad Testnet

Set PRIVATE_KEY to a funded Testnet account as described in Setup, then deploy:

npx hardhat ignition deploy ignition/modules/Counter.ts --network monadTestnet

Set ETHERSCAN_API_KEY, then verify the deployed contract:

npx hardhat verify <CONTRACT_ADDRESS> --network monadTestnet

Deploy to Monad Mainnet

Set PRIVATE_KEY to a funded Mainnet account, then deploy:

npx hardhat ignition deploy ignition/modules/Counter.ts --network monadMainnet

Set ETHERSCAN_API_KEY, then verify the deployed contract:

npx hardhat verify <CONTRACT_ADDRESS> --network monadMainnet

About

Monad flavored Hardhat3

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages