-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy path00_deal_client.ts
More file actions
85 lines (73 loc) · 3.19 KB
/
Copy path00_deal_client.ts
File metadata and controls
85 lines (73 loc) · 3.19 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
/**
* Deploys a contract named "DealClient" using the deployer account and
* constructor arguments set to the deployer address
*
* @param hre HardhatRuntimeEnvironment object.
*/
const deployDealClient: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
/*
On localhost, the deployer account is the one that comes with Hardhat, which is already funded.
When deploying to live networks (e.g `yarn deploy --network sepolia`), the deployer account
should have sufficient balance to pay for the gas fees for contract creation.
You can generate a random account with `yarn generate` which will fill DEPLOYER_PRIVATE_KEY
with a random private key in the .env file (then used on hardhat.config.ts)
You can run the `yarn account` command to check your balance in every network.
*/
const [deployerSigner] = await hre.ethers.getSigners();
const deployer = await deployerSigner.getAddress();
const { deploy } = hre.deployments;
const args = [] as any;
const DealClient = await deploy("DealClient", {
from: deployer,
// Contract constructor arguments
args,
log: true,
// autoMine: can be passed to the deploy function to make the deployment process faster on local networks by
// automatically mining the contract deployment transaction. There is no effect on live networks.
autoMine: true,
waitConfirmations: 3,
});
console.log("🚀 DealClient deployed at: ", DealClient.address);
const DealClientAddress = DealClient.address;
// Check if the --verify flag is present
const shouldVerify = process.env.VERIFY === "true";
const ignoreFilfox = process.env.IGNORE_FILFOX === "true";
const ignoreBlockscout = process.env.IGNORE_BLOCKSCOUT === "true";
if (shouldVerify) {
// Wait for 15 seconds to make sure the contract is deployed
console.log("🕵️♂️ Waiting for 15 seconds to make sure the contract deployment is reflected on the explorer...");
await new Promise(resolve => setTimeout(resolve, 15000));
console.log("🕵️♂️ Verifying the contract on the explorer...");
const filecoinNetworks = ["calibration", "filecoin"];
if (filecoinNetworks.includes(hre.network.name)) {
// Verify the contract on the filfox explorer
if (!ignoreFilfox) {
await hre.run("verify-contract", {
contractName: "DealClient",
});
}
}
if (!ignoreBlockscout) {
try {
await hre.run("verify:verify", {
address: DealClientAddress,
constructorArguments: args,
force: true,
});
} catch (error) {
console.error("Error verifying contract with force:", error);
console.log("🕵️♂️ Verifying the contract on the explorer without forcing verification...");
await hre.run("verify:verify", {
address: DealClientAddress,
constructorArguments: args,
});
}
}
}
};
export default deployDealClient;
// Tags are useful if you have multiple deploy files and only want to run one of them.
// e.g. yarn deploy --tags DealClient
deployDealClient.tags = ["DealClient"];