forked from deltav-deltaverse/nftpacks-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.ts
80 lines (70 loc) · 1.79 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
import dotenv from 'dotenv'
dotenv.config()
import "@nomiclabs/hardhat-waffle";
import "hardhat-abi-exporter";
import "@nomiclabs/hardhat-etherscan";
import { HardhatUserConfig } from "hardhat/config";
import { NetworkUserConfig } from "hardhat/types";
const chainIds = {
ganache: 1337,
goerli: 5,
hardhat: 31337,
kovan: 42,
mainnet: 1,
rinkeby: 4,
ropsten: 3,
matic: 137,
mumbai: 80001,
};
// Ensure that we have all the environment variables we need.
let testPrivateKey: string = process.env.TEST_PRIVATE_KEY || "";
let alchemyKey: string = process.env.ALCHEMY_KEY || "";
let etherscanKey: string = process.env.ETHERSCAN_API_KEY || "";
function createTestnetConfig(network: keyof typeof chainIds): NetworkUserConfig {
if (!alchemyKey) {
throw new Error("Missing ALCHEMY_KEY");
}
let nodeUrl = `https://eth-${network}.alchemyapi.io/v2/${alchemyKey}`;
return {
chainId: chainIds[network],
url: nodeUrl,
accounts: [`${testPrivateKey}`],
};
}
const config: HardhatUserConfig = {
paths: {
artifacts: "./artifacts",
cache: "./cache",
sources: "./contracts",
tests: "./test",
},
solidity: {
version: "0.8.4",
settings: {
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: 800,
},
},
},
abiExporter: {
flat: true,
},
etherscan: {
apiKey: etherscanKey,
},
};
if (testPrivateKey) {
config.networks = {
mainnet: createTestnetConfig("mainnet"),
rinkeby: createTestnetConfig("rinkeby"),
};
}
export default config