-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.ts
119 lines (112 loc) · 3.49 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
import { HardhatUserConfig } from "hardhat/config";
import { NetworkUserConfig } from "hardhat/types";
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import "hardhat-gas-reporter";
import "hardhat-contract-sizer";
import * as dotenv from "dotenv";
dotenv.config();
const infuraApiKey: string | undefined = process.env.INFURA_API_KEY;
if (!infuraApiKey) {
throw new Error("Please set your INFURA_API_KEY in a .env file");
}
const chainIds = {
bsc: 56,
bscTestnet: 97,
mainnet: 1,
goerli: 5,
polygon: 137,
polygonMumbai: 80001,
avalancheFujiTestnet:43113,
sepolia:11155111,
};
function getChainConfig(chain: keyof typeof chainIds): NetworkUserConfig {
let jsonRpcUrl: string;
switch (chain) {
case "bsc":
jsonRpcUrl = "https://bsc-dataseed1.binance.org";
break;
case "bscTestnet":
jsonRpcUrl = "https://data-seed-prebsc-1-s3.binance.org:8545/";
break;
case "polygon":
jsonRpcUrl = "https://rpc.ankr.com/polygon/0243472cd915c54b0589f39c216ae52398f6016de05764b6ba45f0ef59feb741";
break;
case "polygonMumbai":
jsonRpcUrl = "https://matic-mumbai.chainstacklabs.com";
break;
case "avalancheFujiTestnet":
jsonRpcUrl = "https://api.avax-test.network/ext/C/rpc";
break;
default:
jsonRpcUrl = "https://" + chain + ".infura.io/v3/" + infuraApiKey;
}
return {
accounts: [process.env.PRIVATE_KEY],
chainId: chainIds[chain],
url: jsonRpcUrl,
};
}
module.exports = {
solidity: {
version: "0.8.18",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
docgen: {
output: "docs",
pages: "files",
},
paths: {
sources: "./contracts",
cache: "./cache",
artifacts: "./artifacts",
},
networks: {
crossbell: {
url: "https://rpc.crossbell.io",
accounts: [process.env.PRIVATE_KEY],
},
bsc: getChainConfig("bsc"),
bscTestnet: getChainConfig("bscTestnet"),
mainnet: getChainConfig("mainnet"),
goerli: getChainConfig("goerli"),
polygon: getChainConfig("polygon"),
polygonMumbai: getChainConfig("polygonMumbai"),
avalancheFujiTestnet:getChainConfig("avalancheFujiTestnet"),
sepolia:getChainConfig("sepolia"),
},
etherscan: {
apiKey: {
crossbell: "no API key",
bsc: process.env.BSCSCAN_API_KEY || "",
bscTestnet: process.env.BSCSCAN_API_KEY || "",
mainnet: process.env.ETHERSCAN_API_KEY || "",
goerli: process.env.ETHERSCAN_API_KEY || "",
polygon: process.env.POLYGONSCAN_API_KEY || "",
polygonMumbai: process.env.POLYGONSCAN_API_KEY || "",
avalancheFujiTestnet: process.env.AVAX_API_KEY || "",
sepolia: process.env.ETHERSCAN_API_KEY || "",
},
customChains: [
{
network: "crossbell",
chainId: 3737,
urls: {
apiURL: "https://scan.crossbell.io/api",
browserURL: "https://scan.crossbell.io",
},
},
],
},
abiExporter: {
path: "./build-info",
pretty: false,
except: ["@openzeppelin"],
},
} as HardhatUserConfig;