-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.ts
62 lines (55 loc) · 1.27 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
import '@nomiclabs/hardhat-ethers';
import '@nomicfoundation/hardhat-toolbox';
import 'hardhat-deploy';
import fs from 'fs';
import type { HardhatUserConfig } from 'hardhat/config';
import type { NetworkUserConfig } from 'hardhat/src/types/config';
const mnemonicFileName = process.env.MNEMONIC_FILE;
let mnemonic = `${'test '.repeat(11)}junk`;
if (mnemonicFileName != null && fs.existsSync(mnemonicFileName)) {
mnemonic = fs.readFileSync(mnemonicFileName, 'ascii').trim();
}
const infuraUrl = (name: string): string =>
`https://${name}.infura.io/v3/${process.env.INFURA_ID}`;
/**
*
* @param url
*/
function getNetwork(url: string): NetworkUserConfig {
return {
url,
accounts: {
mnemonic,
},
};
}
/**
*
* @param name
*/
function getInfuraNetwork(name: string): NetworkUserConfig {
return getNetwork(infuraUrl(name));
}
const config: HardhatUserConfig = {
paths: {
sources: 'src/contracts',
},
typechain: {
outDir: 'src/contract-types',
target: 'ethers-v5',
},
networks: {
localhost: {
url: 'http://localhost:8545/',
saveDeployments: false,
},
goerli: getInfuraNetwork('goerli'),
},
solidity: {
version: '0.8.15',
settings: {
optimizer: { enabled: true },
},
},
};
export default config;