This project showcases a Hardhat 3 Beta project using the native Node.js test runner (node:test) and the viem library for Ethereum interactions.
To learn more about the Hardhat 3 Beta, please visit the Getting Started guide. To share your feedback, join our Hardhat 3 Beta 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 or to Sepolia.
To run the deployment to a local chain:
npx hardhat ignition deploy ignition/modules/Counter.tsTo run deployments to any of the supported networks (Sepolia, Somnia, or Chiliz), you need an account with funds to send the transaction. The provided Hardhat configuration uses two private keys:
ADMIN_PRIVATE_KEY- Used for contract deployments and main transactionsVERIFIER_PRIVATE_KEY- Used for verification operations (optional)
To set these keys, create a .env file in your project root:
# Required for deployments
ADMIN_PRIVATE_KEY=your_admin_private_key_here
# Optional for verification
VERIFIER_PRIVATE_KEY=your_verifier_private_key_here
# Optional API keys for enhanced Sepolia RPC
ALCHEMY_KEY=your_alchemy_key_here
INFURA_KEY=your_infura_key_hereAfter setting the variable, you can run deployments to any of the supported networks:
# Sepolia testnet
npx hardhat ignition deploy --network sepolia ignition/modules/Counter.ts
# Somnia network
npx hardhat ignition deploy --network somnia ignition/modules/Counter.ts
# Chiliz Chain
npx hardhat ignition deploy --network chiliz ignition/modules/Counter.ts- hardhat: Local development network (default)
- localhost: Local node at http://127.0.0.1:8545
- sepolia: Ethereum Sepolia testnet (chainId: 11155111)
- somnia: Somnia network (chainId: 50311)
- chiliz: Chiliz Chain (chainId: 88888)