-
Notifications
You must be signed in to change notification settings - Fork 39
/
hardhat.config.ts
128 lines (119 loc) · 3.77 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
120
121
122
123
124
125
126
127
128
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)
import path from "path";
import { HardhatUserConfig } from "hardhat/config";
import { HttpNetworkUserConfig } from "hardhat/types";
import { getSingletonFactoryInfo } from "@safe-global/safe-singleton-factory";
import "@nomicfoundation/hardhat-verify";
import "@typechain/hardhat";
import "hardhat-deploy";
import "./src/tasks/deploy-anvil";
import {
Chain,
arbitrum,
arbitrumSepolia,
base,
baseSepolia,
mainnet,
optimism,
optimismSepolia,
sepolia,
} from "viem/chains";
// read MNEMONIC from env variable
let mnemonic = process.env.MNEMONIC;
const networkConfig = (chain: Chain): HttpNetworkUserConfig => {
let url = process.env.RPC_URL || chain.rpcUrls.default.http.at(0);
// support for infura and alchemy URLs through env variables
if (process.env.INFURA_ID && chain.rpcUrls.infura?.http) {
url = `${chain.rpcUrls.infura.http}/${process.env.INFURA_ID}`;
} else if (process.env.ALCHEMY_ID && chain.rpcUrls.alchemy?.http) {
url = `${chain.rpcUrls.alchemy.http}/${process.env.ALCHEMY_ID}`;
}
return {
chainId: chain.id,
url,
accounts: mnemonic ? { mnemonic } : undefined,
};
};
const config: HardhatUserConfig = {
networks: {
hardhat: mnemonic ? { accounts: { mnemonic } } : {},
localhost: {
url: process.env.RPC_URL || "http://localhost:8545",
accounts: mnemonic ? { mnemonic } : undefined,
},
arbitrum: networkConfig(arbitrum),
arbitrum_sepolia: networkConfig(arbitrumSepolia),
base: networkConfig(base),
base_sepolia: networkConfig(baseSepolia),
mainnet: networkConfig(mainnet),
sepolia: networkConfig(sepolia),
optimism: networkConfig(optimism),
optimism_sepolia: networkConfig(optimismSepolia),
},
solidity: {
version: "0.8.23",
settings: {
optimizer: {
enabled: true,
},
},
},
paths: {
artifacts: "artifacts",
deploy: "deploy",
deployments: "deployments",
},
deterministicDeployment: (network: string) => {
// networks will use another deterministic deployment proxy
// https://github.com/safe-global/safe-singleton-factory
const chainId = parseInt(network);
const info = getSingletonFactoryInfo(chainId);
if (info) {
return {
factory: info.address,
deployer: info.signerAddress,
funding: (
BigInt(info.gasPrice) * BigInt(info.gasLimit)
).toString(),
signedTx: info.transaction,
};
} else {
console.warn(
`unsupported deterministic deployment for network ${network}`,
);
return undefined;
}
},
typechain: {
outDir: "src/types",
target: "ethers-v6",
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
customChains: [
{
chainId: 421614,
network: "arbitrum_sepolia",
urls: {
apiURL: "https://api-sepolia.arbiscan.io/api",
browserURL: "https://sepolia.arbiscan.io",
},
},
{
chainId: 11155420,
network: "optimism_sepolia",
urls: {
apiURL: "https://sepolia-optimistic.etherscan.io/api",
browserURL: "https://sepolia-optimistic.etherscan.io",
},
},
],
},
namedAccounts: {
deployer: {
default: 0,
},
},
};
export default config;