-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
105 lines (98 loc) · 2.55 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
import '@nomicfoundation/hardhat-toolbox';
import '@openzeppelin/hardhat-upgrades';
import { config as dotenvConfig } from 'dotenv';
import 'hardhat-deploy';
import type { HardhatUserConfig } from 'hardhat/config';
import type { HardhatNetworkAccountUserConfig, NetworkUserConfig } from 'hardhat/types';
import { resolve } from 'path';
import 'tsconfig-paths/register';
import { DeployNetworks } from '~types';
import { getEnv } from './common/config';
const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || './.env';
dotenvConfig({
path: resolve(__dirname, dotenvConfigPath),
});
function getAccounts() {
return [
`0x${getEnv('OWNER_PRIVATE_KEY')}`,
`0x${getEnv('USER1_PRIVATE_KEY')}`,
`0x${getEnv('USER2_PRIVATE_KEY')}`,
`0x${getEnv('USER3_PRIVATE_KEY')}`,
`0x${getEnv('OWNER2_PRIVATE_KEY')}`,
];
}
function getNetworkAccounts(): HardhatNetworkAccountUserConfig[] {
return getAccounts().map((account) => ({
privateKey: account,
balance: '1000000000000000000',
}));
}
function getChainConfig(
chain: keyof DeployNetworks,
chainId?: number,
): NetworkUserConfig & { url?: string } {
return {
chainId,
url: getEnv(`${chain.toUpperCase()}_PROVIDER_URL`),
accounts: getAccounts(),
};
}
export const defaultNetwork: keyof DeployNetworks = 'bsc';
// export const defaultNetwork: keyof DeployNetworks = 'bscTestnet';
const config: HardhatUserConfig = {
defaultNetwork,
etherscan: {
apiKey: {
bsc: getEnv('BSC_SCAN_API_KEY'),
bscTestnet: getEnv('BSCTESTNET_SCAN_API_KEY'),
},
},
gasReporter: {
currency: 'USD',
enabled: false,
excludeContracts: [],
src: './contracts',
},
networks: {
hardhat: {
forking: {
enabled: false,
url: getChainConfig(defaultNetwork).url ?? '',
blockNumber: 39656567, // <-- edit here
},
initialBaseFeePerGas: 0,
mining: {
auto: true,
},
gasPrice: 0,
accounts: getNetworkAccounts(),
},
bsc: getChainConfig('bsc'),
bscTestnet: getChainConfig('bscTestnet'),
},
paths: {
artifacts: './artifacts',
cache: './cache',
sources: './contracts',
tests: './test',
},
solidity: {
version: '0.8.19',
settings: {
metadata: {
bytecodeHash: 'none',
},
// Disable the optimizer when debugging
// https://hardhat.org/hardhat-network/#solidity-optimizer-support
optimizer: {
enabled: true,
runs: 800,
},
},
},
typechain: {
// outDir: "types",
target: 'ethers-v6',
},
};
export default config;