generated from PaulRBerg/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
hardhat.config.ts
147 lines (137 loc) · 4.11 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
import {NetworkNameMapping} from './utils/helpers';
import '@nomicfoundation/hardhat-chai-matchers';
import '@nomicfoundation/hardhat-toolbox';
import '@nomiclabs/hardhat-etherscan';
import '@openzeppelin/hardhat-upgrades';
import '@typechain/hardhat';
import {config as dotenvConfig} from 'dotenv';
import {BigNumber} from 'ethers';
import 'hardhat-deploy';
import 'hardhat-gas-reporter';
import {extendEnvironment, HardhatUserConfig} from 'hardhat/config';
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import type {NetworkUserConfig} from 'hardhat/types';
import {resolve} from 'path';
import 'solidity-coverage';
const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || './.env';
dotenvConfig({path: resolve(__dirname, dotenvConfigPath)});
if (!process.env.INFURA_API_KEY) {
throw new Error('INFURA_API_KEY in .env not set');
}
const apiUrls: NetworkNameMapping = {
arbitrumOne: 'https://arbitrumOne.infura.io/v3/',
arbitrumGoerli: 'https://arbitrumGoerli.infura.io/v3/',
mainnet: 'https://mainnet.infura.io/v3/',
goerli: 'https://goerli.infura.io/v3/',
polygon: 'https://polygon-mainnet.infura.io/v3/',
polygonMumbai: 'https://polygon-mumbai.infura.io/v3/',
};
const networks: {[index: string]: NetworkUserConfig} = {
hardhat: {
chainId: 31337,
forking: {
url: `${
apiUrls[
process.env.HARDHAT_FORK_NETWORK
? process.env.HARDHAT_FORK_NETWORK
: 'mainnet'
]
}${process.env.INFURA_API_KEY}`,
},
},
arbitrumOne: {
chainId: 42161,
url: `${apiUrls.arbitrumOne}${process.env.INFURA_API_KEY}`,
},
arbitrumGoerli: {
chainId: 421613,
url: `${apiUrls.arbitrumGoerli}${process.env.INFURA_API_KEY}`,
},
mainnet: {
chainId: 1,
url: `${apiUrls.mainnet}${process.env.INFURA_API_KEY}`,
},
goerli: {
chainId: 5,
url: `${apiUrls.goerli}${process.env.INFURA_API_KEY}`,
},
polygon: {
chainId: 137,
url: `${apiUrls.polygon}${process.env.INFURA_API_KEY}`,
},
polygonMumbai: {
chainId: 80001,
url: `${apiUrls.polygonMumbai}${process.env.INFURA_API_KEY}`,
},
};
// Uses hardhats private key if none is set. DON'T USE THIS ACCOUNT FOR DEPLOYMENTS
const accounts = process.env.PRIVATE_KEY
? process.env.PRIVATE_KEY.split(',')
: ['0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'];
for (const network in networks) {
// special treatement for hardhat
if (network.startsWith('hardhat')) {
networks[network].accounts = accounts.map(account => ({
privateKey: account,
balance: BigNumber.from(10).pow(20).toString(), // Set balance to 100 ETH
}));
continue;
}
networks[network].accounts = accounts;
}
// Extend HardhatRuntimeEnvironment
extendEnvironment((hre: HardhatRuntimeEnvironment) => {
hre.aragonToVerifyContracts = [];
});
const config: HardhatUserConfig = {
defaultNetwork: 'hardhat',
etherscan: {
apiKey: {
arbitrumOne: process.env.ARBISCAN_API_KEY || '',
arbitrumGoerli: process.env.ARBISCAN_API_KEY || '',
mainnet: process.env.ETHERSCAN_API_KEY || '',
goerli: process.env.ETHERSCAN_API_KEY || '',
polygon: process.env.POLYGONSCAN_API_KEY || '',
polygonMumbai: process.env.POLYGONSCAN_API_KEY || '',
},
},
namedAccounts: {
deployer: 0,
},
gasReporter: {
currency: 'USD',
enabled: process.env.REPORT_GAS === 'true' ? true : false,
excludeContracts: [],
src: './contracts',
coinmarketcap: process.env.COINMARKETCAP_API_KEY,
},
networks,
paths: {
artifacts: './artifacts',
cache: './cache',
sources: './contracts',
tests: './test',
deploy: './deploy',
},
solidity: {
version: '0.8.17',
settings: {
metadata: {
// Not including the metadata hash
// https://github.com/paulrberg/hardhat-template/issues/31
bytecodeHash: 'none',
},
// Disable the optimizer when debugging
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
optimizer: {
enabled: true,
runs: 800,
},
},
},
typechain: {
outDir: 'typechain',
target: 'ethers-v5',
},
};
export default config;