forked from smartcontractkit/functions-hardhat-starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.js
156 lines (148 loc) · 4.37 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
require("@nomicfoundation/hardhat-toolbox")
require("hardhat-contract-sizer")
require("./tasks")
require("dotenv").config()
// Set one of the following RPC endpoints (required)
let MAINNET_RPC_URL = process.env.MAINNET_RPC_URL
let POLYGON_MAINNET_RPC_URL = process.env.POLYGON_MAINNET_RPC_URL
let MUMBAI_RPC_URL = process.env.MUMBAI_RPC_URL
let GOERLI_RPC_URL = process.env.GOERLI_RPC_URL
let SEPOLIA_RPC_URL = process.env.SEPOLIA_RPC_URL
// Ignore default values from .env.example
if (GOERLI_RPC_URL === "https://goerli.infura.io/v3/ExampleKey") {
GOERLI_RPC_URL = undefined
}
if (SEPOLIA_RPC_URL === "https://sepolia.infura.io/v3/ExampleKey") {
SEPOLIA_RPC_URL = undefined
}
if (MUMBAI_RPC_URL === "https://polygon-mumbai.g.alchemy.com/v2/ExampleKey") {
MUMBAI_RPC_URL = undefined
}
// Ensure one of the RPC endpoints has been set
if (!MAINNET_RPC_URL && !POLYGON_MAINNET_RPC_URL && !MUMBAI_RPC_URL && !GOERLI_RPC_URL && !SEPOLIA_RPC_URL) {
throw Error(
"One of the following environment variables must be set: MAINNET_RPC_URL, GOERLI_RPC_URL, SEPOLIA_RPC_URL, POLYGON_MAINNET_RPC_URL, or MUMBAI_RPC_URL"
)
}
// Set EVM private key (required)
const PRIVATE_KEY = process.env.PRIVATE_KEY
if (!PRIVATE_KEY) {
throw Error("Set the PRIVATE_KEY environment variable with your EVM wallet private key")
}
// Set a specific bock number to fork (optional)
const FORKING_BLOCK_NUMBER = isNaN(process.env.FORKING_BLOCK_NUMBER)
? undefined
: parseInt(process.env.FORKING_BLOCK_NUMBER)
// Your API key for Etherscan, obtain one at https://etherscan.io/ (optional)
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY
const POLYGONSCAN_API_KEY = process.env.POLYGONSCAN_API_KEY
// Enable gas reporting (optional)
const REPORT_GAS = process.env.REPORT_GAS?.toLowerCase() === "true" ? true : false
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
defaultNetwork: "hardhat",
solidity: {
compilers: [
{
version: "0.8.7",
settings: {
optimizer: {
enabled: true,
runs: 1_000,
},
},
},
{
version: "0.6.6",
settings: {
optimizer: {
enabled: true,
runs: 1_000,
},
},
},
{
version: "0.4.24",
settings: {
optimizer: {
enabled: true,
runs: 1_000,
},
},
},
],
},
networks: {
hardhat: {
allowUnlimitedContractSize: true,
hardfork: "merge",
forking: {
url: MAINNET_RPC_URL ?? POLYGON_MAINNET_RPC_URL ?? MUMBAI_RPC_URL ?? GOERLI_RPC_URL ?? SEPOLIA_RPC_URL,
blockNumber: FORKING_BLOCK_NUMBER,
enabled: true,
},
chainId: 31337,
accounts: process.env.PRIVATE_KEY
? [
{
privateKey: process.env.PRIVATE_KEY,
balance: "10000000000000000000000",
},
]
: [],
},
goerli: {
url: GOERLI_RPC_URL ?? "UNSET",
accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [],
chainId: 5,
},
mainnet: {
url: MAINNET_RPC_URL ?? "UNSET",
accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [],
chainId: 1,
},
polygon: {
url: POLYGON_MAINNET_RPC_URL ?? "UNSET",
accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [],
chainId: 137,
},
mumbai: {
url: MUMBAI_RPC_URL ?? "UNSET",
accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [],
},
sepolia: {
url: SEPOLIA_RPC_URL || "UNSET",
accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [],
chainId: 11155111,
},
},
etherscan: {
// yarn hardhat verify --network <NETWORK> <CONTRACT_ADDRESS> <CONSTRUCTOR_PARAMETERS>
apiKey: {
mainnet: ETHERSCAN_API_KEY,
polygon: POLYGONSCAN_API_KEY,
goerli: ETHERSCAN_API_KEY,
sepolia: ETHERSCAN_API_KEY,
polygonMumbai: POLYGONSCAN_API_KEY,
},
},
gasReporter: {
enabled: REPORT_GAS,
currency: "USD",
outputFile: "gas-report.txt",
noColors: true,
},
contractSizer: {
runOnCompile: false,
only: ["FunctionsConsumer", "AutomatedFunctionsConsumer", "FunctionsBillingRegistry"],
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./build/cache",
artifacts: "./build/artifacts",
},
mocha: {
timeout: 200000, // 200 seconds max for running tests
},
}