# 5. Deployment

### Hardhat Ignition Deployment (Recommended)

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

```javascript
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)

```sh
# 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)

```javascript
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

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://luntra.gitbook.io/luntra-infrastructure/smart-contract-deployment-guide-on-hardhat/5.-deployment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
