-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhardhat.config.ts
103 lines (91 loc) · 2.33 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
import { task } from "hardhat/config";
import { HardhatUserConfig, NetworkUserConfig } from "hardhat/types";
import 'hardhat-deploy';
import 'hardhat-deploy-ethers';
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-waffle";
import "hardhat-gas-reporter";
import "@nomiclabs/hardhat-etherscan";
import { config as dotenvConfig } from "dotenv";
import { resolve } from "path";
dotenvConfig({ path: resolve(__dirname, "./.env") });
const chainIds = {
hardhat: 31337,
bsctestnet: 97,
bscmainnet: 56,
};
const MNEMONIC = process.env.MNEMONIC || "";
const MNEMONIC_MAINNET = process.env.MNEMONIC_MAINNET || "";
const BSCSCAN_API_KEY = process.env.BSCSCAN_API_KEY || "";
const MORALIS_API_KEY = process.env.MORALIS_API_KEY || "";
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);
}
});
function createNetworkConfig(network: keyof typeof chainIds): NetworkUserConfig {
let _mnemonic: string;
if(network == "bscmainnet"){
_mnemonic = MNEMONIC_MAINNET;
}else{
_mnemonic = MNEMONIC;
}
return {
accounts: {
count: 10,
initialIndex: 0,
mnemonic: _mnemonic,
path: "m/44'/60'/0'/0",
},
chainId: chainIds[network],
url: "https://" + "speedy-nodes-nyc.moralis.io/" + MORALIS_API_KEY + "/bsc/" + network.substr(3)
};
}
const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
solidity: {
compilers: [
{
version: "0.8.4",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
],
},
networks: {
hardhat: {
accounts: {
mnemonic: MNEMONIC,
},
chainId: chainIds.hardhat,
forking: {
url: "https://" + "speedy-nodes-nyc.moralis.io/" + MORALIS_API_KEY + "/bsc/mainnet"
},
},
bsctestnet: createNetworkConfig("bsctestnet"),
bscmainnet: createNetworkConfig("bscmainnet"),
},
etherscan: {
apiKey: BSCSCAN_API_KEY
},
gasReporter: {
currency: "USD",
gasPrice: 100,
enabled: false,
},
typechain: {
outDir: "typechain",
target: "ethers-v5",
},
mocha: {
timeout: 20000000
}
};
export default config;