-
Notifications
You must be signed in to change notification settings - Fork 3
/
hardhat.config.ts
109 lines (102 loc) · 2.5 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
import '@nomiclabs/hardhat-waffle';
import * as dotenv from 'dotenv';
import 'hardhat-deploy';
import 'hardhat-deploy-ethers';
import { HardhatUserConfig } from 'hardhat/config';
import '@typechain/hardhat';
import 'hardhat-gas-reporter';
import 'solidity-coverage';
import './tasks/index';
import '@nomiclabs/hardhat-etherscan';
import 'hardhat-contract-sizer';
dotenv.config();
const {
INFURA,
ACCOUNT_PRIVATE_KEY,
MNEMONIC,
ETHERSCAN_API_KEY,
CI,
REPORT_GAS,
COINMARKETCAP_API_KEY,
REPORT_SIZE,
REPORT_GAS_PRICE,
} = process.env;
//if using infura, you can add new networks by adding the name as it is seen in the infura url
const INFURA_NETWORKS = [
'mainnet',
'rinkeby',
'arbitrum-mainnet',
'arbitrum-rinkeby',
];
const networks = CI
? [] // Do not initialize network info on github CI
: ['rinkeby'];
const accounts = ACCOUNT_PRIVATE_KEY
? //Private key overrides mnemonic - leave pkey empty in .env if using mnemonic
[`0x${ACCOUNT_PRIVATE_KEY}`]
: {
mnemonic: MNEMONIC,
path: "m/44'/60'/0'/0",
initialIndex: 0,
count: 10,
};
/**
* Given the name of a network build a Hardhat Network object
* @param {string} _network - the string name of the network
* @return {INetwork} - the Hardhat Network object
*/
const makeNetwork = (_network: string): any => {
if (INFURA_NETWORKS.includes(_network))
return {
url: `https://${_network}.infura.io/v3/${INFURA}`,
gasMultiplier: 2,
accounts,
};
return {};
};
const config: HardhatUserConfig & {
typechain: { outDir: string; target: string };
} = {
typechain: {
outDir: 'artifacts/types',
target: 'ethers-v5',
},
solidity: {
version: '0.8.6',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
networks: networks.reduce((obj: any, entry) => {
obj[entry] = makeNetwork(entry);
return obj;
}, {}),
// if you don't want to rely on infura network builder module
// networks: {
// rinkeby: {
// url: `https://rinkeby.infura.io/v3/${INFURA}`,
// account: [`0x${ACCOUNT_PRIVATE_KEY}`]
// }
// }
etherscan: {
apiKey: ETHERSCAN_API_KEY,
},
contractSizer: {
alphaSort: true,
runOnCompile: REPORT_SIZE === 'true',
disambiguatePaths: false,
},
gasReporter: {
enabled: REPORT_GAS === 'true',
currency: 'USD',
gasPrice: Number.parseInt(REPORT_GAS_PRICE ?? '50'),
coinmarketcap: `${COINMARKETCAP_API_KEY || ''}`,
},
mocha: {
delay: true,
},
};
export default config;