-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhardhat.config.ts
More file actions
130 lines (116 loc) · 3.84 KB
/
hardhat.config.ts
File metadata and controls
130 lines (116 loc) · 3.84 KB
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
import "@nomicfoundation/hardhat-toolbox";
import { resolve } from "path";
import "@matterlabs/hardhat-zksync-solc";
import "@matterlabs/hardhat-zksync-deploy";
// import "@matterlabs/hardhat-zksync-upgradable";
import "@matterlabs/hardhat-zksync-verify";
import "@openzeppelin/hardhat-upgrades";
import { config as dotenvConfig } from "dotenv";
import { NetworkUserConfig } from "hardhat/types";
interface HardhatArguments {
network?: string;
valsetUpdate?: string;
}
const hardhatArguments: HardhatArguments = process.argv.reduce((acc, arg, index, array) => {
if (arg.startsWith("--network")) {
acc.network = array[index + 1];
}
if (arg.startsWith("--valset_update")) {
acc.valsetUpdate = array[index + 1];
}
return acc;
}, {} as HardhatArguments);
dotenvConfig({ path: resolve(__dirname, "./.env") });
const chainIds = {
optimism: 10
};
// Ensure that we have all the environment variables we need.
const private_key = process.env.PRIVATE_KEY;
if (!private_key) {
throw new Error("Please set your PRIVATE_KEY in a .env file");
}
const infuraApiKey = process.env.INFURA_API_KEY;
if (!infuraApiKey) {
throw new Error("Please set your INFURA_API_KEY in a .env file");
}
function getChainConfig(network: keyof typeof chainIds): NetworkUserConfig {
let url = "";
url = "https://" + network + ".infura.io/v3/" + infuraApiKey;
if (network == "optimism") {
url = "https://mainnet.optimism.io";
}
return {
accounts: [`${process.env.PRIVATE_KEY}`],
chainId: chainIds[network],
url,
};
}
const config = {
defaultNetwork: "hardhat",
gasReporter: {
currency: "USD",
enabled: true,
excludeContracts: [],
src: "./contracts",
},
networks: {
optimism: getChainConfig("optimism"),
},
solidity: {
version: "0.8.18",
settings: {
evmVersion: "paris",
metadata: {
// Not including the metadata hash
// https://github.com/paulrberg/solidity-template/issues/31
bytecodeHash: "none",
},
// You should disable the optimizer when debugging
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
optimizer: {
enabled: true,
runs: 999999,
},
},
},
paths: {
artifacts: "./artifacts",
cache: "./cache",
sources: "./contracts",
tests: "./test",
},
zksolc: {
version: "1.4.0", // optional.
settings: {
// compilerPath: "zksolc", // optional. Ignored for compilerSource "docker". Can be used if compiler is located in a specific folder
libraries: {}, // optional. References to non-inlinable libraries
missingLibrariesPath: "./.zksolc-libraries-cache/missingLibraryDependencies.json", // optional. This path serves as a cache that stores all the libraries that are missing or have dependencies on other libraries. A `hardhat-zksync-deploy` plugin uses this cache later to compile and deploy the libraries, especially when the `deploy-zksync:libraries` task is executed
isSystem: false, // optional. Enables Yul instructions available only for zkSync system contracts and libraries
forceEvmla: false, // optional. Falls back to EVM legacy assembly if there is a bug with Yul
optimizer: {
enabled: true, // optional. True by default
mode: "3" // optional. 3 by default, z to optimize bytecode size
},
experimental: {
dockerImage: "", // deprecated
tag: "" // deprecated
}
}
},
typechain: {
outDir: "typechain",
target: "ethers-v6"
},
etherscan: {
apiKey: {
optimisticEthereum: "D922B3PHZXNRX6DJIMQEB4MMNBI7KPW7RC"
},
sourcify: {
// Disabled by default
// Doesn't need an API key
enabled: true
},
customChains: []
},
};
export default config;