forked from HausDAO/Baal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.ts
263 lines (251 loc) · 6.24 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
import dotenv from "dotenv";
import * as fs from "fs";
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
// import "@openzeppelin/hardhat-upgrades";
import "solidity-coverage";
import "hardhat-contract-sizer";
import "hardhat-abi-exporter";
import "hardhat-deploy";
import "./tasks/setup";
dotenv.config();
/*
when compiled contracts do not exist,
importing "tasks/setup" will fail the compile task itself.
this is a circular dependency that exists on the tasks themselves.
conditionally loading tasks if the artifacts folder exists
allows the config to skip the first compile.
*/
// if (fs.existsSync("./artifacts")) {
// import("./tasks/setup");
// }
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
const defaultNetwork = "localhost";
const infuraKey = () => {
return process.env.INFURA_API_KEY || '' // <---- YOUR INFURA ID! (or it won't work)
};
const mnemonic = () => {
try {
return process.env.MNEMONIC || fs.readFileSync("./mnemonic.txt").toString().trim();
} catch (e) {
if (defaultNetwork !== "localhost") {
console.log(
"☢️ WARNING: No mnemonic file created for a deploy account. Try `yarn run generate` and then `yarn run account`."
);
}
}
return "";
}
const explorerApiKey = (networkName: string) => {
const fromEnv = () => {
switch (networkName) {
case "ethereum":
return process.env.ETHERSCAN_API_KEY;
case "gnosis":
return process.env.GNOSISSCAN_API_KEY;
case "polygon":
return process.env.POLYGONSCAN_API_KEY;
case "optimism":
return process.env.OPTIMISTICSCAN_API_KEY;
case "arbitrumOne":
return process.env.ARBISCAN_API_KEY;
default:
break;
}
}
return fromEnv() || '';
}
const config: HardhatUserConfig = {
networks: {
localhost: {
url: "http://localhost:8545",
/*
notice no mnemonic here? it will just use account 0 of the hardhat node to deploy
(you can put in a mnemonic here to set the deployer locally)
*/
},
mainnet: {
url: `https://mainnet.infura.io/v3/${infuraKey()}`,
accounts: {
mnemonic: mnemonic(),
},
verify: {
etherscan: {
apiKey: explorerApiKey('ethereum'),
},
},
},
goerli: {
url: `https://goerli.infura.io/v3/${infuraKey()}`,
// gas: 5000000,
// gasPrice: 100000000000,
// gasMultiplier: 2,
accounts: process.env.ACCOUNT_PK
? [process.env.ACCOUNT_PK]
: {
mnemonic: mnemonic(),
},
verify: {
etherscan: {
apiKey: explorerApiKey('ethereum'),
},
},
},
xdai: {
url: "https://rpc.gnosischain.com/",
gas: 5000000,
gasPrice: 8000000000,
accounts: {
mnemonic: mnemonic(),
},
verify: {
etherscan: {
apiKey: explorerApiKey('gnosis'),
},
}
},
gnosis: {
url: "https://rpc.gnosischain.com/",
gas: 5000000,
gasPrice: 8000000000,
accounts: {
mnemonic: mnemonic(),
},
verify: {
etherscan: {
apiKey: explorerApiKey('gnosis'),
},
},
},
polygon: {
url: `https://polygon-mainnet.infura.io/v3/${infuraKey()}`,
accounts: {
mnemonic: mnemonic(),
},
verify: {
etherscan: {
apiKey: explorerApiKey('polygon'),
},
},
},
polygonMumbai: {
url: `https://polygon-mumbai.infura.io/v3/${infuraKey()}`,
accounts: {
mnemonic: mnemonic(),
},
verify: {
etherscan: {
apiKey: explorerApiKey('polygon'),
},
},
},
arbitrumOne: {
url: `https://arbitrum-mainnet.infura.io/v3/${infuraKey()}`,
accounts: {
mnemonic: mnemonic(),
},
verify: {
etherscan: {
apiKey: explorerApiKey('arbitrumOne'),
},
},
},
optimisticEthereum: {
url: `https://optimism-mainnet.infura.io/v3/${infuraKey()}`,
accounts: {
mnemonic: mnemonic(),
},
verify: {
etherscan: {
apiKey: explorerApiKey('optimism'),
},
},
},
},
etherscan: {
// Your API key for Etherscan
// Obtain one at https://etherscan.io/
// apiKey: "61ED96HQAY6PASTEWRXN6AMYQEKM8SYTRY" // etherscan
apiKey: {
gnosis: explorerApiKey('gnosis'),
xdai: explorerApiKey('gnosis'),
goerli: explorerApiKey('ethereum'),
mainnet: explorerApiKey('ethereum'),
polygon: explorerApiKey('polygon'),
polygonMumbai: explorerApiKey('polygon'),
arbitrumOne: explorerApiKey('arbitrumOne'),
optimisticEthereum: explorerApiKey('optimism'),
},
customChains: [
{
network: "gnosis",
chainId: 100,
urls: {
apiURL: "https://api.gnosisscan.io/api",
browserURL: "https://gnosisscan.io/",
},
},
// can only have one chainId 100 at a time
// {
// network: "xdai",
// chainId: 100,
// urls: {
// apiURL: "https://blockscout.com/xdai/mainnet/api",
// browserURL: "https://blockscout.com/xdai/mainnet/",
// }
// }
]
},
solidity: {
compilers: [
{
version: "0.8.7",
settings: {
optimizer: {
enabled: true,
runs: 200,
// coverage only
// details: {
// yul: true
// },
},
},
},
{
version: "0.8.10",
settings: {
optimizer: {
enabled: true,
runs: 200,
// coverage only
// details: {
// yul: true
// },
},
},
}
],
},
namedAccounts: {
deployer: 0,
},
abiExporter: {
path: './abi',
clear: true,
flat: true,
except: ['@gnosis.pm', '@openzeppelin'],
},
typechain: {
outDir: "src/types",
target: "ethers-v5",
},
gasReporter: {
currency: "USD",
enabled: process.env.REPORT_GAS === 'true',
excludeContracts: [],
src: "./contracts",
coinmarketcap: process.env.COINMARKETCAP_API_KEY,
},
};
export default config;