-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
68 lines (61 loc) · 1.72 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
import { HardhatUserConfig } from "hardhat/config";
import { config as dotenvConfig } from "dotenv";
import { resolve } from "path";
import "@nomicfoundation/hardhat-toolbox";
import "@nomiclabs/hardhat-etherscan";
import { NetworkUserConfig } from "hardhat/types";
const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || "./.env";
dotenvConfig({ path: resolve(__dirname, dotenvConfigPath) });
const INFURA_API_KEY: string | undefined = process.env.INFURA_API_KEY;
if (!INFURA_API_KEY) {
throw new Error("Infura API Key is missing from the .env file. Aborting...");
}
const PRIVATE_KEY: string = process.env.PRIVATE_KEY || "";
if (!PRIVATE_KEY) {
throw new Error("Private key is missing from the .env file. Aborting...");
}
const chainsConfig = {
goerli: {
chainId: 5,
rpcURL: `https://goerli.infura.io/v3/${INFURA_API_KEY}`,
},
hardhat: {
chainId: 31337,
rpcURL: "",
},
};
function getChainConfig(chainAbbreviation: keyof typeof chainsConfig): NetworkUserConfig {
const chainConfig = chainsConfig[chainAbbreviation];
return {
accounts: [PRIVATE_KEY],
/* accounts: {
count: 10,
mnemonic: MNEMONIC,
path: "m/44'/60'/0'/0",
}, */
chainId: chainConfig.chainId,
url: chainConfig.rpcURL,
};
}
const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
etherscan: {
apiKey: { goerli: process.env.ETHERSCAN_API_KEY || "" },
},
networks: {
hardhat: {
forking: {
url: `https://goerli.infura.io/v3/${INFURA_API_KEY}`,
},
},
goerli: getChainConfig("goerli"),
},
paths: {
artifacts: "./artifacts",
cache: "./cache",
sources: "./contracts",
tests: "./test",
},
solidity: "0.8.17",
};
export default config;