-
Notifications
You must be signed in to change notification settings - Fork 45
/
hardhat.config.js
113 lines (109 loc) · 2.72 KB
/
hardhat.config.js
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
require("solidity-coverage");
require("@nomiclabs/hardhat-truffle5");
require("@nomiclabs/hardhat-ethers");
require("@nomicfoundation/hardhat-verify");
require("dotenv").config();
const {
WALLET_PROVIDER_METHOD,
CREDENTIALS_ADDRESS,
CREDENTIALS_KEYSTORE,
CREDENTIALS_PASSWORD,
MNEMONIC,
PRIVATE_KEY,
} = process.env;
module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
chainId: 122,
accounts: {
mnemonic: "test test test test test test test test test test test fuse",
path: "m/44'/60'/0'/0",
initialIndex: 0,
count: 20,
passphrase: "",
accountsBalance: "1000000000000000000000000",
},
},
fuse: {
url: "https://rpc.fuse.io",
chainId: 122,
accounts: getSigners(),
},
spark: {
url: "https://rpc.fusespark.io",
chainId: 123,
accounts: getSigners(),
},
devnet: {
url: "http://34.38.118.140:8545",
chainId: 123,
accounts: getSigners(),
allowUnlimitedContractSize: true,
},
},
solidity: {
version: "0.4.24",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts",
},
mocha: {
timeout: 40000,
},
etherscan: {
apiKey: {
spark: "abc",
fuse: "abc",
},
customChains: [
{
network: "spark",
chainId: 123,
urls: {
apiURL: "https://explorer.fusespark.io/api/",
browserURL: "https://explorer.fusespark.io",
},
},
{
network: "fuse",
chainId: 122,
urls: {
apiURL: "https://explorer.fuse.io/api/",
browserURL: "https://explorer.fuse.io",
},
},
],
},
};
function getSigners() {
let signers = [];
if (WALLET_PROVIDER_METHOD === "keystore") {
const fs = require("fs");
const os = require("os");
const path = require("path");
const keythereum = require("keythereum");
const keystore_dir = path.join(os.homedir(), CREDENTIALS_KEYSTORE);
const password_dir = path.join(os.homedir(), CREDENTIALS_PASSWORD);
const password = fs.readFileSync(password_dir, "utf8");
const keyobj = keythereum.importFromFile(CREDENTIALS_ADDRESS, keystore_dir);
const privateKey = keythereum.recover(password, keyobj);
signers.push(privateKey.toString("hex"));
} else if (WALLET_PROVIDER_METHOD === "mnemonic") {
const wallet = Wallet.fromMnemonic(MNEMONIC);
const privateKey = wallet.getPrivateKeyString();
signers.push(privateKey);
} else if (WALLET_PROVIDER_METHOD === "privateKey") {
signers.push(PRIVATE_KEY);
}
return signers;
}