5. Deployment

Create Ignition Module (ignition/modules/Lock.js)

const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules");

const JAN_1ST_2030 = 1893456000;
const ONE_GWEI = 1_000_000_000n;

module.exports = buildModule("LockModule", (m) => {
  const unlockTime = m.getParameter("unlockTime", JAN_1ST_2030);
  const lockedAmount = m.getParameter("lockedAmount", ONE_GWEI);

  const lock = m.contract("Lock", [unlockTime], {
    value: lockedAmount,
  });

  return { lock };
});

Deploy to Luntra Chain(you can directly deploy by below command without creating ignition module)

# Deploy to Luntra Infrastructure
npx hardhat ignition deploy ./ignition/modules/Lock.js --network luntraChain

# Deploy with custom parameters
npx hardhat ignition deploy ./ignition/modules/Lock.js --network luntraChain --parameters '{"LockModule": {"unlockTime": 1735689600, "lockedAmount": "1000000000000000000"}}'

Alternative: Script-based Deployment

Create deployment script (scripts/deploy.js)

const { ethers } = require("hardhat");

async function main() {
  const [deployer] = await ethers.getSigners();

  console.log("Deploying contracts with the account:", deployer.address);
  console.log("Account balance:", (await ethers.provider.getBalance(deployer.address)).toString());

  const Lock = await ethers.getContractFactory("Lock");
  const unlockTime = Math.floor(Date.now() / 1000) + 3600; // 1 hour from now
  const lock = await Lock.deploy(unlockTime, { value: ethers.parseEther("0.01") });

  console.log("Lock deployed to:", await lock.getAddress());
  console.log("Unlock time:", unlockTime);
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

Run deployment script

npx hardhat run scripts/deploy.js --network luntraChain

Last updated