-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.js
165 lines (157 loc) · 4.08 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
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
require('dotenv').config()
require('@nomiclabs/hardhat-ganache')
require('@nomiclabs/hardhat-ethers')
require('@nomiclabs/hardhat-truffle5')
require('@nomiclabs/hardhat-etherscan')
require('@openzeppelin/hardhat-upgrades')
require('hardhat-gas-reporter')
const { random, template } = require('lodash')
const GAS_PRICE_DEFAULT = 10000000000
const GAS_MULTIPLIER_DEFAULT = 1
const chains = require('./chains.json')
const scanners = require('./scanners.json')
// const INFURA_API_KEY = process.env.INFURA_API_KEY
const keys = {
INFURA_API_KEY: process.env.INFURA_API_KEY
}
const getScanUrl = () => {
const chainId = scanners.current
const result = scanners.url[chainId]
return result
}
const getKey = () => {
const chainId = scanners.current
const result = scanners.apikey[chainId]
return result
}
// This is a sample Buidler task. To learn how to create your own go to
// https://buidler.dev/guides/create-task.html
task('accounts', 'Prints the list of accounts', async () => {
const accounts = await ethers.getSigners()
for (const account of accounts) {
console.log(await account.getAddress())
}
})
const getChainInfo = (chainId) =>
chains.find((chain) => chain.chainId === parseInt(chainId, 10)) || {}
const concatKeys = (url, keys) => {
const temp = template(url)
return temp(keys)
}
const getUrl = (chainId) => {
const finded = getChainInfo(chainId)
const rpcNodes = finded.rpc
const randomIndex = random(0, rpcNodes.length - 1)
return concatKeys(rpcNodes[randomIndex], keys)
}
// You have to export an object to set up your config
// This object can have the following optional entries:
// defaultNetwork, networks, solc, and paths.
// Go to https://buidler.dev/config/ to learn more
module.exports = {
defaultNetwork: 'hardhat',
networks: {
rinkeby: {
url: getUrl(4),
chainId: 4,
gas: 'auto',
gasPrice: GAS_PRICE_DEFAULT,
gasMultiplier: GAS_MULTIPLIER_DEFAULT,
accounts: { mnemonic: process.env.MNEMONIC }
},
goerli: {
url: getUrl(5),
chainId: 5,
gas: 'auto',
gasPrice: GAS_PRICE_DEFAULT,
gasMultiplier: GAS_MULTIPLIER_DEFAULT,
accounts: { mnemonic: process.env.MNEMONIC }
},
mainnet: {
url: getUrl(1),
chainId: 1,
gas: 'auto',
gasPrice: GAS_PRICE_DEFAULT,
gasMultiplier: GAS_MULTIPLIER_DEFAULT,
accounts: { mnemonic: process.env.MNEMONIC }
},
bsctestnet: {
url: getUrl(97),
chainId: 97,
gas: 4251144,
gasPrice: GAS_PRICE_DEFAULT,
gasMultiplier: GAS_MULTIPLIER_DEFAULT,
accounts: { mnemonic: process.env.MNEMONIC }
},
bscmainnet: {
url: getUrl(56),
chainId: 56,
gas: 'auto',
gasPrice: GAS_PRICE_DEFAULT,
gasMultiplier: GAS_MULTIPLIER_DEFAULT,
accounts: { mnemonic: process.env.MNEMONIC }
},
polygon: {
url: getUrl(137),
chainId: 137,
gas: 'auto',
gasPrice: GAS_PRICE_DEFAULT,
gasMultiplier: GAS_MULTIPLIER_DEFAULT,
accounts: { mnemonic: process.env.MNEMONIC }
},
polygonmumbai: {
url: getUrl(80001),
chainId: 80001,
gas: 'auto',
gasPrice: GAS_PRICE_DEFAULT,
gasMultiplier: GAS_MULTIPLIER_DEFAULT,
accounts: { mnemonic: process.env.MNEMONIC }
}
},
// This is a sample solc configuration that specifies which version of solc to use
solidity: {
compilers: [
{
version: '0.5.16',
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
{
version: '0.8.2'
},
{
version: '0.8.9',
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
{
version: '0.6.6',
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
}
]
},
gasReporter: {
currency: 'USD',
gasPrice: 21,
enabled: true
},
etherscan: {
// url: process.env.ETHERSCAN_URL,
// apiKey: process.env.ETHERSCAN_KEY
url: getScanUrl(),
apiKey: getKey()
}
}