-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path00_deploy_lock_contract.ts
More file actions
46 lines (38 loc) · 1.56 KB
/
Copy path00_deploy_lock_contract.ts
File metadata and controls
46 lines (38 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { time } from "@nomicfoundation/hardhat-network-helpers";
import type { DeployFunction, DeployResult } from "hardhat-deploy/types";
import type { HardhatRuntimeEnvironment } from "hardhat/types";
import { preDeploy } from "../utils/contracts";
import { toWei } from "../utils/format";
import { verifyContract } from "../utils/verify";
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { getNamedAccounts, getChainId, deployments } = hre;
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = await getChainId();
const CONTRACT_NAME = "Lock";
const currentTimestampInSeconds = await time.latest();
const ONE_YEAR_IN_SECS = time.duration.years(1);
const unlockTime = currentTimestampInSeconds + ONE_YEAR_IN_SECS;
const lockedAmount = toWei("1");
const args: [number] = [unlockTime];
await preDeploy(deployer, CONTRACT_NAME);
const deployResult: DeployResult = await deploy(CONTRACT_NAME, {
// Learn more about args here: https://www.npmjs.com/package/hardhat-deploy#deploymentsdeploy
from: deployer,
args: args,
log: true,
value: lockedAmount.toString(),
// waitConfirmations: 5,
});
// You don't want to verify on localhost
if (chainId !== "31337" && chainId !== "1337") {
const contractPath = `contracts/${CONTRACT_NAME}.sol:${CONTRACT_NAME}`;
await verifyContract({
contractPath: contractPath,
contractAddress: deployResult.address,
args: deployResult.args || [],
});
}
};
export default func;
func.tags = ["Lock"];