forked from boringcrypto/BoringSolidity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.js
181 lines (167 loc) · 4.93 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// hardhat.config.js
require("dotenv/config")
require("@nomiclabs/hardhat-etherscan")
require("@nomiclabs/hardhat-solhint")
// require("@nomiclabs/hardhat-solpp")
require("@tenderly/hardhat-tenderly")
require("@nomiclabs/hardhat-waffle")
require("hardhat-abi-exporter")
require("hardhat-deploy")
require("hardhat-deploy-ethers")
require("hardhat-gas-reporter")
require("hardhat-spdx-license-identifier")
require("hardhat-watcher")
require("solidity-coverage")
const { normalizeHardhatNetworkAccountsConfig } = require("hardhat/internal/core/providers/util")
const { BN, bufferToHex, privateToAddress, toBuffer } = require("ethereumjs-util")
const { removeConsoleLog } = require("hardhat-preprocessor")
const accounts = {
mnemonic: process.env.MNEMONIC || "test test test test test test test test test test test junk",
accountsBalance: "990000000000000000000",
}
// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (_, { config }) => {
const networkConfig = config.networks["hardhat"]
const accounts = normalizeHardhatNetworkAccountsConfig(networkConfig.accounts)
console.log("Accounts")
console.log("========")
for (const [index, account] of accounts.entries()) {
const address = bufferToHex(privateToAddress(toBuffer(account.privateKey)))
const privateKey = bufferToHex(toBuffer(account.privateKey))
const balance = new BN(account.balance).div(new BN(10).pow(new BN(18))).toString(10)
console.log(`Account #${index}: ${address} (${balance} ETH)
Private Key: ${privateKey}
`)
}
})
task("named-accounts", "Prints the list of named account", async () => {
console.log({ namedAccounts: await getNamedAccounts() })
})
task("block", "Prints the current block", async (_, { ethers }) => {
const block = await ethers.provider.getBlockNumber()
console.log("Current block: " + block)
})
task("pairs", "Prints the list of pairs", async () => {
// ...
})
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
abiExporter: {
path: "./build/abi",
//clear: true,
flat: true,
// only: [],
// except: []
},
defaultNetwork: "hardhat",
etherscan: {
// Your API key for Etherscan
// Obtain one at https://etherscan.io/
apiKey: process.env.ETHERSCAN_API_KEY,
},
gasReporter: {
enabled: process.env.REPORT_GAS ? true : false,
currency: "USD",
coinmarketcap: process.env.COINMARKETCAP_API_KEY,
excludeContracts: ["contracts/mocks/", "contracts/libraries/"],
},
hardhat: {
forking: {
url: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_API_KEY}`,
},
},
// mocha: {
// timeout: 0,
// },
namedAccounts: {
deployer: {
default: 0, // here this will by default take the first account as deployer
1: 0, // similarly on mainnet it will take the first account as deployer. Note though that depending on how hardhat network are configured, the account 0 on one network can be different than on another
},
alice: {
default: 1,
// hardhat: 0,
},
bob: {
default: 2,
// hardhat: 0,
},
carol: {
default: 3,
// hardhat: 0,
},
fee: {
// Default to 1
default: 1,
// Multi sig feeTo address
// 1: "",
},
dev: {
// Default to 1
default: 1,
// Borings devTo address
// 1: "",
},
},
networks: {
hardhat: {
chainId: 31337,
accounts,
},
// mainnet: {
// url: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
// accounts: [process.env.PRIVATE_KEY],
// gasPrice: 120 * 1000000000,
// chainId: 1,
// },
ropsten: {
url: `https://ropsten.infura.io/v3/${process.env.INFURA_API_KEY}`,
accounts,
chainId: 3,
live: true,
saveDeployments: true,
},
kovan: {
url: `https://kovan.infura.io/v3/${process.env.INFURA_API_KEY}`,
accounts,
chainId: 42,
live: true,
saveDeployments: true,
},
// rinkeby: {
// url: `https://rinkeby.infura.io/v3/${process.env.INFURA_API_KEY}`,
// accounts: [process.env.PRIVATE_KEY],
// chainId: 4,
// },
},
preprocess: {
eachLine: removeConsoleLog((bre) => bre.network.name !== "hardhat" && bre.network.name !== "localhost"),
},
solidity: {
version: "0.8.9",
settings: {
optimizer: {
enabled: true,
runs: 500,
},
},
},
spdxLicenseIdentifier: {
overwrite: false,
runOnCompile: true,
},
tenderly: {
project: process.env.TENDERLY_PROJECT,
username: process.env.TENDERLY_USERNAME,
},
watcher: {
compile: {
tasks: ["compile"],
files: ["./contracts"],
verbose: true,
},
},
}