This project demonstrates a basic Hardhat use case optimized for Monad. It comes with a sample contract, a test for that contract, and a Hardhat Ignition module that deploys that contract.
hardhat-monad/
├── contracts/ # Smart contract source files
│ └── Lock.sol # Sample time-locked wallet contract
├── ignition/ # Hardhat Ignition deployment modules
│ └── modules/
│ └── Lock.ts # Deployment configuration for Lock contract
├── test/ # Test files
│ └── Lock.ts # Tests for the Lock contract
├── .env.example # Example environment variables file
├── hardhat.config.ts # Hardhat configuration
├── package.json # Project dependencies
└── tsconfig.json # TypeScript configuration
- Node.js (v16+)
-
Clone this repository:
git clone https://github.com/portdeveloper/hardhat-monad.git cd hardhat-monad -
Install dependencies:
npm install
-
Create a
.envfile based on.env.example:cp .env.example .env
-
Add your private key to the
.envfile:PRIVATE_KEY=your_private_key_here⚠️ IMPORTANT: Never commit your.envfile or expose your private key.
Run tests with Hardhat:
npx hardhat testThis project uses Hardhat Ignition for deployments, which makes it easy to manage complex deployment procedures.
Run hardhat node by running:
npx hardhat nodeTo deploy the contract to the local hardhat node, run the following command:
npx hardhat ignition deploy ignition/modules/Lock.tsnpx hardhat ignition deploy ignition/modules/Lock.ts --network monadTestnetTo redeploy the same code to a different address use the command below:
npx hardhat ignition deploy ignition/modules/Lock.ts --network monadTestnet --resetYou can customize deployment parameters:
npx hardhat ignition deploy ignition/modules/Lock.ts --network monadTestnet --parameters '{"unlockTime": 1893456000, "lockedAmount": "1000000000000000"}'This project is configured to use Sourcify for contract verification on Monad. After deployment, you can verify your contract with:
npx hardhat verify <contract_address> --network monadTestnetOnce verified, you can view your contract on the Monad Explorer.
The sample Lock contract is a simple time-locked wallet that:
- Accepts ETH during deployment
- Locks funds until a specified timestamp
- Allows only the owner to withdraw once the time has passed
You can modify the unlock time in ignition/modules/Lock.ts or pass it as a parameter during deployment.
- Refer to docs.monad.xyz for Monad-specific documentation
- Visit Hardhat Documentation for Hardhat help
- Check Hardhat Ignition Guide for deployment assistance
This project is licensed under the MIT License.