Repository navigation
Expand file tree
/
Copy pathhardhat.config.js
More file actions
134 lines (130 loc) Β· 3.67 KB
/
Copy pathhardhat.config.js
File metadata and controls
134 lines (130 loc) Β· 3.67 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
131
132
133
134
import "@nomicfoundation/hardhat-ethers";
import dotenv from "dotenv";
dotenv.config();
// Read environment variables
const PRIVATE_KEY = process.env.PRIVATE_KEY;
const MNEMONIC = process.env.MNEMONIC;
const RPC_URL = process.env.RPC_URL;
const CHAIN_ID = parseInt(process.env.CHAIN_ID || "1", 10);
// Parse accounts config (PRIVATE_KEY takes precedence over MNEMONIC)
let accountsConfig;
if (
PRIVATE_KEY &&
PRIVATE_KEY !== "0xYourPrivateKeyHere" &&
PRIVATE_KEY.trim().length > 10
) {
accountsConfig = [
PRIVATE_KEY.startsWith("0x") ? PRIVATE_KEY : `0x${PRIVATE_KEY}`,
];
} else if (
MNEMONIC &&
MNEMONIC !== "your mnemonic here" &&
MNEMONIC.trim().length > 0
) {
accountsConfig = {
mnemonic: MNEMONIC.trim(),
path: "m/44'/60'/0'/0",
initialIndex: 0,
count: 10,
};
} else {
accountsConfig = [];
}
/** @type import('hardhat/config').HardhatUserConfig */
export default {
solidity: {
compilers: [
{
// Must match the deployment profile of the dev repo EXACTLY so the bytecode is
// reproducible/verifiable on-chain (C-1). It did not: this pinned 0.8.20 while the dev
// repo deploys with 0.8.28, so a third party reproducing the build got different
// bytecode - regressing C-1 precisely where it is meant to hold.
//
// The old rationale ("0.8.20 avoids PUSH0") was mistaken: PUSH0 is gated by
// `evmVersion`, not by the compiler version, and "paris" below already excludes it on
// every solc release. So 0.8.28 is equally safe on the non-PUSH0 chains in the deploy
// set, and it is the version the test suite actually exercises.
version: "0.8.28",
settings: {
optimizer: {
enabled: true,
runs: 1,
},
viaIR: true,
evmVersion: "paris",
},
},
],
},
networks: {
hardhat: {
chainId: 1337,
},
localhost: {
url: "http://127.0.0.1:8545",
chainId: 1337,
},
// Preset Mainnets
ethereum: {
url: process.env.ETHEREUM_RPC_URL || "https://eth.llamarpc.com",
chainId: 1,
accounts: accountsConfig,
},
bsc: {
url: process.env.BSC_RPC_URL || "https://binance.llamarpc.com",
chainId: 56,
accounts: accountsConfig,
},
polygon: {
url: process.env.POLYGON_RPC_URL || "https://polygon.llamarpc.com",
chainId: 137,
accounts: accountsConfig,
},
arbitrum: {
url: process.env.ARBITRUM_RPC_URL || "https://arbitrum.llamarpc.com",
chainId: 42161,
accounts: accountsConfig,
},
optimism: {
url: process.env.OPTIMISM_RPC_URL || "https://optimism.llamarpc.com",
chainId: 10,
accounts: accountsConfig,
},
base: {
url: process.env.BASE_RPC_URL || "https://mainnet.base.org",
chainId: 8453,
accounts: accountsConfig,
},
// Preset Testnets
sepolia: {
url:
process.env.SEPOLIA_RPC_URL ||
"https://ethereum-sepolia-rpc.publicnode.com",
chainId: 11155111,
accounts: accountsConfig,
},
amoy: {
url: process.env.AMOY_RPC_URL || "https://rpc-amoy.polygon.technology",
chainId: 80002,
accounts: accountsConfig,
},
bscTestnet: {
url:
process.env.BSC_TESTNET_RPC_URL ||
"https://bsc-testnet-rpc.publicnode.com",
chainId: 97,
accounts: accountsConfig,
},
// Mainnet / any EVM chain - configured dynamically via .env (custom / mainnet aliases)
mainnet: {
url: RPC_URL || "",
chainId: CHAIN_ID,
accounts: accountsConfig,
},
custom: {
url: RPC_URL || "",
chainId: CHAIN_ID,
accounts: accountsConfig,
},
},
};