This repository has been archived by the owner on Nov 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathhardhat.config.ts
158 lines (143 loc) · 4.07 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
148
149
150
151
152
153
154
155
156
157
158
import * as dotenv from "dotenv";
import { HardhatUserConfig, task, types } from "hardhat/config";
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import * as chai from "chai";
import chaiAsPromised from "chai-as-promised";
import spies from "chai-spies";
import "hardhat-gas-reporter";
import "solidity-coverage";
dotenv.config();
// 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 (_taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
task("generateMnemonic", "Generates and displays a random mnemonic").setAction(
async (_params, hre) => {
const wallet = hre.ethers.Wallet.createRandom();
console.log(wallet.mnemonic.phrase);
},
);
// Don't run this unless you really need to...
task("privateKeys", "Prints the private keys for accounts")
.addParam("force", "Whether the command should be run", false, types.boolean)
.setAction(async ({ force }: { force: boolean }, hre) => {
if (!force) {
throw new Error("are you sure you want to run this task? (--force true)");
}
const separator = "-".repeat(3);
console.log(separator);
for (let i = 0; i < accounts.count; i++) {
const wallet = hre.ethers.Wallet.fromMnemonic(
accounts.mnemonic,
`m/44'/60'/0'/0/${i}`,
);
console.log(`${i}: ${wallet.address}`);
console.log(wallet.privateKey);
console.log(separator);
}
});
task("sendEth", "Sends ETH to an address")
.addParam("address", "Address to send ETH to", undefined, types.string)
.addOptionalParam("amount", "Amount of ETH to send", "1.0")
.setAction(
async ({ address, amount }: { address: string; amount: string }, hre) => {
const [account0] = await hre.ethers.getSigners();
console.log(`${account0.address} -> ${address} ${amount} ETH`);
const txnRes = await account0.sendTransaction({
to: address,
value: hre.ethers.utils.parseEther(amount),
});
await txnRes.wait();
},
);
// Do any needed pre-test setup here.
task("test").setAction(async (_taskArgs, _hre, runSuper) => {
chai.use(chaiAsPromised);
chai.use(spies);
await runSuper();
});
// Accounts used for testing and deploying
const accounts = {
mnemonic: `${process.env.MAIN_MNEMONIC}`,
count: 5,
};
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.15",
settings: {
optimizer: {
enabled: true,
runs: 1,
},
},
},
{
version: "0.7.6",
settings: {
optimizer: {
enabled: true,
runs: 1000,
},
},
},
{
version: "0.6.12",
settings: {
optimizer: {
enabled: true,
runs: 1000,
},
},
},
],
},
networks: {
hardhat: {
chainId: 1337,
initialBaseFeePerGas: 0, // workaround from https://github.com/sc-forks/solidity-coverage/issues/652#issuecomment-896330136 . Remove when that issue is closed.
accounts,
blockGasLimit: 30_000_000,
},
gethDev: {
url: `http://localhost:8545`,
accounts,
// issue: https://github.com/NomicFoundation/hardhat/issues/3136
// workaround: https://github.com/NomicFoundation/hardhat/issues/2672#issuecomment-1167409582
timeout: 100_000,
},
arbitrum_goerli: {
// chainId: 421613
url: process.env.ARBITRUM_GOERLI_URL,
accounts,
},
arbitrum: {
// chainId: 42161
url: process.env.ARBITRUM_URL,
accounts,
gasPrice: 700000000,
},
optimism_goerli: {
url: process.env.OPTIMISM_GOERLI_URL,
accounts,
},
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
currency: "USD",
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
mocha: {
timeout: 120000,
},
};
export default config;