-
Notifications
You must be signed in to change notification settings - Fork 6
/
hardhat.config.js
135 lines (125 loc) · 3.23 KB
/
hardhat.config.js
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
require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-etherscan");
require("hardhat-deploy");
require("hardhat-deploy-ethers");
require('hardhat-abi-exporter');
require('hardhat-log-remover');
require("hardhat-gas-reporter");
const INFURA_KEY = process.env.INFURA_KEY
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY
const DEPLOYER_ADDRESS = process.env.DEPLOYER_ADDRESS
const DEPLOYER_PRIVATE_KEY = process.env.DEPLOYER_PRIVATE_KEY
const DISPATCHER_FACTORY_ADMIN_ADDRESS = process.env.DISPATCHER_FACTORY_ADMIN_ADDRESS
const DISPATCHER_FACTORY_ADMIN_PRIVATE_KEY = process.env.DISPATCHER_FACTORY_ADMIN_PRIVATE_KEY
const REPORT_GAS = process.env.REPORT_GAS
const CMC_API_KEY = process.env.CMC_API_KEY
// Default Hardhat network config
let hardhatConfig = {
live: false,
saveDeployments: true,
tags: ["test"]
}
// Local network config
let localhostConfig = {
url: 'http://localhost:8545',
live: false,
saveDeployments: true,
tags: ["local"]
}
// Rinkeby testnet config
let rinkebyConfig = {
url: "https://rinkeby.infura.io/v3/" + INFURA_KEY,
chainId: 4,
live: true,
saveDeployments: true,
tags: ["staging"],
}
// Mainnet config
let mainnetConfig = {
url: "https://mainnet.infura.io/v3/" + INFURA_KEY,
chainId: 1,
live: true,
saveDeployments: true,
tags: ["prod", "mainnet", "live"]
}
if (DEPLOYER_PRIVATE_KEY && DEPLOYER_PRIVATE_KEY.length > 0) {
rinkebyConfig.accounts = [DEPLOYER_PRIVATE_KEY]
mainnetConfig.accounts = [DEPLOYER_PRIVATE_KEY]
if (DISPATCHER_FACTORY_ADMIN_PRIVATE_KEY && DISPATCHER_FACTORY_ADMIN_PRIVATE_KEY.length > 0) {
rinkebyConfig.accounts.push(DISPATCHER_FACTORY_ADMIN_PRIVATE_KEY)
mainnetConfig.accounts.push(DISPATCHER_FACTORY_ADMIN_PRIVATE_KEY)
}
}
// Hardhat tasks
// Documentation: https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async () => {
const accounts = await ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
// Hardhat Config
// Documentation: https://hardhat.org/config/
// Deploy add-ons: https://hardhat.org/plugins/hardhat-deploy.html
module.exports = {
solidity: {
compilers: [
{
version: "0.7.4",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
{
version: "0.8.3",
settings: {
optimizer: {
enabled: true,
runs: 99999
}
}
}
]
},
defaultNetwork: "hardhat",
networks: {
hardhat: hardhatConfig,
localhost: localhostConfig,
rinkeby: rinkebyConfig,
mainnet: mainnetConfig
},
etherscan: {
apiKey: ETHERSCAN_API_KEY
},
namedAccounts: {
deployer: {
default: 0,
1: DEPLOYER_ADDRESS,
4: DEPLOYER_ADDRESS
},
admin: {
default: 1,
1: DISPATCHER_FACTORY_ADMIN_ADDRESS,
4: DISPATCHER_FACTORY_ADMIN_ADDRESS
}
},
paths: {
deploy: 'deploy',
deployments: 'deployments',
imports: `imports`
},
abiExporter: {
path: './abis',
clear: true,
flat: true
},
gasReporter: {
enabled: REPORT_GAS && REPORT_GAS == "true" ? true : false,
coinmarketcap: CMC_API_KEY,
currency: 'USD',
showTimeSpent: true
}
};