Hardhat
Contents3 sections
Start a Hardhat 3 project for Monad or add Monad to an existing project.
Hardhat 3 is a development environment for compiling, testing, deploying, and verifying smart contracts. You can start with the Monad template or add Monad to an existing Hardhat 3 project.
Hardhat 3 requires Node.js v22.13.0 or later.
Choose one setup path:
- New project: Clone the Monad template and work inside the cloned repository.
- Existing project: Do not clone the template into your project. Merge only the configuration shown below into your existing
hardhat.config.ts.
Start with the Monad template
The Monad Hardhat 3 template includes:
- Monad Testnet and Mainnet network configuration
- Foundry-compatible Solidity tests and TypeScript tests using
node:test - Viem for TypeScript interactions
- Hardhat Ignition deployment modules
- Sourcify and MonadScan contract verification
Clone and test the template:
git clone https://github.com/monad-developers/hardhat3-monad.git
cd hardhat3-monad
npm install
npx hardhat test
See the template's README for local, Testnet, and Mainnet deployment commands.
Configure an existing Hardhat 3 project
Merge the following compiler and network settings into your hardhat.config.ts. Keep any plugins and other project-specific settings already in the file.
import { configVariable, defineConfig } from "hardhat/config";
export default defineConfig({
solidity: {
version: "0.8.31",
settings: {
evmVersion: "osaka",
},
},
networks: {
monadTestnet: {
type: "http",
url: "https://testnet-rpc.monad.xyz",
accounts: [configVariable("PRIVATE_KEY")],
chainId: 10143,
},
monadMainnet: {
type: "http",
url: "https://rpc.monad.xyz",
accounts: [configVariable("PRIVATE_KEY")],
chainId: 143,
},
},
});
Never put a private key directly in hardhat.config.ts or commit it to version control. Provide PRIVATE_KEY through Hardhat's configuration variable system, using the PRIVATE_KEY environment variable or the Hardhat keystore.
The osaka EVM target is required when compiling contracts for Monad, and Solidity 0.8.31 requires Hardhat 3.1.0 or later. For the canonical RPC URLs, chain IDs, and explorer URLs, see Network Information and Network Information - Testnet.
Confirm the updated project still compiles and passes its tests:
npx hardhat compile
npx hardhat test