Deploy a contract in Monad testnet using Hardhat
Prep your workspace
Node ≥ 20 & npm ≥ 10 installed.
In a fresh folder:
npm init -y && npm i -D hardhat @nomicfoundation/hardhat-ethers ethers
Run
npx hardhat
→ Create a TypeScript project when prompted (or JS if you prefer).
Put Jenius contract in place
Drop
MarginTradingHelper.sol
into contracts/.
Add Monad Testnet to
hardhat.config.ts
import { HardhatUserConfig } from "hardhat/config"; import "@nomicfoundation/hardhat-ethers"; const config: HardhatUserConfig = { solidity: "0.8.24", networks: { monadTestnet: { url: process.env.MONAD_RPC || "https://testnet-rpc.monad.xyz", chainId: 10143, accounts: [process.env.PRIVATE_KEY!], // 0.05 MON from faucet required }, }, }; export default config;
Create a deploy script (scripts/deploy.ts)(Ask Jenius for that)
import { ethers } from "hardhat"; async function main() { const helper = await ethers.deployContract("MarginTradingHelper", [ "0xb2f82D0f38dc453D596Ad40A37799446Cc89274A", // aPriori vault "0xb2f82D0f38dc453D596Ad40A37799446Cc89274A", // aprMON ERC‑20 "0x4B186949F31FCA0aD08497Df9169a6bEbF0e26ef", // Kuru MarginAccount "0xc816865f172d640d93712C68a7E1F83F3fA63235" // Kuru Router ]); await helper.waitForDeployment(); console.log("Helper deployed at", helper.target); } main().catch(console.error);
Compile & deploy
npx hardhat compile MONAD_RPC=https://testnet-rpc.monad.xyz \ PRIVATE_KEY=0x<yourPrivKey> \ npx hardhat run scripts/deploy.ts --network monadTestnet
On success Hardhat prints the new address.
Verify (optional) — use Hardhat’s verify task with chain ID 10143 to publish source on MonadExplorer.
Update env & test
Add
HELPER_ADDR=<printed-address>
to.env
.Run your Jenius bot; it will pick up the helper automatically.
Troubleshoot
“insufficient funds” → grab more MON from faucet.
*chainId mismatch*
→ confirm Hardhat network is set to10143
.Gas under‑priced → pass
gasLimit: 3_000_000
or run with-gas-price <hexWei>
(testnet forgiving).Now your Jenius‑generated helper is live on Monad Testnet—ready for bots, front‑ends, or further Hardhat scripts.
Last updated