-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhardhat.config.ts
More file actions
86 lines (75 loc) · 2.07 KB
/
Copy pathhardhat.config.ts
File metadata and controls
86 lines (75 loc) · 2.07 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
import { existsSync } from "fs";
import { loadEnvFile } from "process";
if (existsSync(".env")) {
loadEnvFile();
}
import hardhatEthers from "@nomicfoundation/hardhat-ethers";
import hardhatEthersChaiMatchers from "@nomicfoundation/hardhat-ethers-chai-matchers";
import hardhatMocha from "@nomicfoundation/hardhat-mocha";
import hardhatNetworkHelpers from "@nomicfoundation/hardhat-network-helpers";
import hardhatTypechain from "@nomicfoundation/hardhat-typechain";
import hardhatVerify from "@nomicfoundation/hardhat-verify";
import type { HardhatUserConfig } from "hardhat/config";
function normalizePrivateKey(value: string | undefined): string | undefined {
if (value === undefined || value.trim() === "") {
return undefined;
}
return value.startsWith("0x") ? value : `0x${value}`;
}
const deployerKey = normalizePrivateKey(process.env.DEPLOYER_KEY);
const networks: NonNullable<HardhatUserConfig["networks"]> = {
hardhat: {
type: "edr-simulated", // <-- for the built-in Hardhat network
chainId: 31337,
initialBaseFeePerGas: 0,
},
localhost: {
type: "http", // for a local node via RPC
url: process.env.LOCAL_RPC_URL ?? "http://127.0.0.1:8545",
chainId: 31337,
},
};
if (process.env.SEPOLIA_RPC_URL) {
networks.sepolia = {
type: "http",
url: process.env.SEPOLIA_RPC_URL,
chainId: 11155111,
accounts: deployerKey ? [deployerKey] : [],
};
}
const config: HardhatUserConfig = {
paths: {
sources: "./examples/contracts",
tests: "./examples/test_examples",
},
solidity: {
version: "0.8.28",
settings: {
evmVersion: "prague",
optimizer: {
enabled: true,
runs: 200,
},
},
},
networks,
verify: {
etherscan: process.env.ETHERSCAN_API_KEY
? {
enabled: true,
apiKey: process.env.ETHERSCAN_API_KEY,
}
: {
enabled: false,
},
},
plugins: [
hardhatEthers,
hardhatTypechain,
hardhatMocha,
hardhatEthersChaiMatchers,
hardhatNetworkHelpers,
hardhatVerify,
],
};
export default config;