-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhardhat.config.ts
163 lines (142 loc) · 4.29 KB
/
hardhat.config.ts
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import { task } from "hardhat/config";
import "@nomiclabs/hardhat-waffle";
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-web3";
import "@nomiclabs/hardhat-ethers";
import * as dotenv from "dotenv";
dotenv.config();
/** npx hardhat TASK_NAME --network matic_prod */
task("deploy_NFT", "Deploy the smart contracts", async (args, hre) => {
const TOKEN_NAME = process.env.TOKEN_NAME ?? "Niftymints";
const TOKEN_SYMBOL = process.env.TOKEN_SYMBOL ?? "NFTY";
const OWNER = process.env.OWNER ?? "0x" + "0".repeat(40);
console.log(`Deploying ${TOKEN_NAME} with symbol ${TOKEN_SYMBOL}`);
const NFT = await hre.ethers.getContractFactory("NFT");
const smartContract = await NFT.deploy(TOKEN_NAME, TOKEN_SYMBOL, OWNER);
await smartContract.deployed();
await txWait(smartContract.deployTransaction.hash, 5, hre.web3);
console.log(`Deployed contact at ${smartContract.address}`);
await hre
.run("verify:verify", {
address: smartContract.address,
constructorArguments: [TOKEN_NAME, TOKEN_SYMBOL, OWNER],
})
.catch((e) => {
if (e.message.toLowerCase().includes("already verified")) {
console.log("Verified!");
} else {
throw e;
}
});
});
task(
"deploy_token_migrator",
"Deploy the smart contract for Token Migrator",
async (args, hre) => {
const TokenMigrator = await hre.ethers.getContractFactory("TokenMigrator");
const smartContract = await TokenMigrator.deploy();
await smartContract.deployed();
await txWait(smartContract.deployTransaction.hash, 5, hre.web3);
console.log(`Deployed contact at ${smartContract.address}`);
await hre
.run("verify:verify", {
address: smartContract.address,
})
.catch((e) => {
if (e.message.toLowerCase().includes("already verified")) {
console.log("Verified!");
} else {
throw e;
}
});
}
);
task(
"deploy_clone_collection",
"Deploy the smart contract for Collection Cloner",
async (args, hre) => {
const CloneContract = await hre.ethers.getContractFactory(
"CloneCollection"
);
const smartContract = await CloneContract.deploy();
await smartContract.deployed();
await txWait(smartContract.deployTransaction.hash, 5, hre.web3);
console.log(`Deployed contact at ${smartContract.address}`);
await hre
.run("verify:verify", {
address: smartContract.address,
})
.catch((e) => {
if (e.message.toLowerCase().includes("already verified")) {
console.log("Verified!");
} else {
throw e;
}
});
}
);
task(
"deploy_airdrop_tokens",
"Deploy the smart contract for Airdropping tokens",
async (args, hre) => {
const AirdropperContract = await hre.ethers.getContractFactory(
"AirdropTokens"
);
const smartContract = await AirdropperContract.deploy();
await smartContract.deployed();
await txWait(smartContract.deployTransaction.hash, 5, hre.web3);
console.log(`Deployed contact at ${smartContract.address}`);
await hre
.run("verify:verify", {
address: smartContract.address,
})
.catch((e) => {
if (e.message.toLowerCase().includes("already verified")) {
console.log("Verified!");
} else {
throw e;
}
});
}
);
async function txWait(txHash: string, confirmations: number, web3: any) {
const tx = (await web3.eth.getTransaction(txHash)) as any;
let currentBlock = await web3.eth.getBlockNumber();
while (currentBlock - tx.blockNumber < confirmations) {
await new Promise((resolve) => setTimeout(resolve, 1000));
currentBlock = await web3.eth.getBlockNumber();
}
}
export default {
solidity: {
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
networks: {
mumbai_dev: {
url: process.env.ALCHEMY_DEV_URL ?? "https://rpc-mumbai.maticvigil.com",
accounts: [process.env.PRIVATE_KEY_DEV],
},
matic_prod: {
url: process.env.ALCHEMY_PROD_URL,
accounts: [process.env.PRIVATE_KEY_PROD],
},
},
etherscan: {
apiKey: process.env.POLYGONSCAN_KEY,
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts",
},
mocha: {
timeout: 20000,
},
};