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. To share your feedback, join our Hardhat3 Telegram group or open an issue in our GitHub issue tracker.
This example project includes:
- A simple Hardhat configuration file.
- Foundry-compatible Solidity unit tests.
- TypeScript integration tests using
node:test, the new Node.js native test runner, andviem. - Examples demonstrating how to connect to different types of networks, including locally simulating OP mainnet.
To run all the tests in the project, execute the following command:
npx hardhat testYou can also selectively run the Solidity or node:test tests:
npx hardhat test solidity
npx hardhat test nodejsThis 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.
To run the deployment to a local chain:
npx hardhat ignition deploy ignition/modules/Counter.tsTo run the deployment to Monad Testnet, you need an account with funds to send the transaction. The provided Hardhat configuration includes a Configuration Variable called PRIVATE_KEY, which you can use to set the private key of the account you want to use.
You can set the PRIVATE_KEY variable using the hardhat-keystore plugin or by setting it as an environment variable.
To set the PRIVATE_KEY config variable using hardhat-keystore:
npx hardhat keystore set PRIVATE_KEYAfter setting the variable, you can run the deployment to Monad Testnet:
npx hardhat ignition deploy ignition/modules/Counter.ts --network monadTestnetTo verify the deployed contract on Monad Testnet:
npx hardhat verify <CONTRACT_ADDRESS> --network monadTestnetTo run the deployment to Monad Mainnet, ensure you have set your PRIVATE_KEY as described above.
Deploy to Monad Mainnet:
npx hardhat ignition deploy ignition/modules/Counter.ts --network monadMainnetTo verify the deployed contract on Monad Mainnet:
npx hardhat verify <CONTRACT_ADDRESS> --network monadMainnet