-
Notifications
You must be signed in to change notification settings - Fork 5
/
truffle.js
78 lines (71 loc) · 2.54 KB
/
truffle.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
require('dotenv').config();
const Web3 = require("web3");
const DEFAULT_GAS_WEI = 4600000;
const DEFAULT_ADDRESS_COUNT = 3;
const DEFAULT_ADDRESS_INDEX = 0;
const DEFAULT_GAS_GWEI_PRICE = "20";
const web3 = new Web3();
const HDWalletProvider = require("truffle-hdwallet-provider");
const addressCountValue = process.env["ADDRESS_COUNT_KEY"] || DEFAULT_ADDRESS_COUNT;
const mnemonicKeyValue = process.env["MNEMONIC_KEY"] || '';
const infuraKeyValue = process.env["INFURA_KEY"] || '';
if(infuraKeyValue === '' || mnemonicKeyValue === '') {
console.log('WARNING: The infura key or/and mnemonic key are empty. They should not be empty.');
}
const gasKeyValue = process.env["GAS_WEI_KEY"] || DEFAULT_GAS_WEI;
const gasPriceKeyValue = process.env["GAS_PRICE_GWEI_KEY"] || DEFAULT_GAS_GWEI_PRICE;
module.exports = {
web3: Web3,
networks : {
geth: {
host: "localhost",
port: 8045,
network_id: "*"
},
ganache: {
host: "127.0.0.1",
port: 7545,
network_id: "*"
},
infuraRinkeby: {
provider: function() {
return new HDWalletProvider(mnemonicKeyValue, `https://rinkeby.infura.io/${infuraKeyValue}`, DEFAULT_ADDRESS_INDEX, addressCountValue);
},
gas: gasKeyValue,
gasPrice: web3.utils.toWei(gasPriceKeyValue, "gwei"),
network_id: "5",
},
infuraKovan: {
provider: function() {
return new HDWalletProvider(mnemonicKeyValue, `https://kovan.infura.io/${infuraKeyValue}`, DEFAULT_ADDRESS_INDEX, addressCountValue);
},
gas: gasKeyValue,
gasPrice: web3.utils.toWei(gasPriceKeyValue, "gwei"),
network_id: "4",
},
infuraRopsten: {
provider: function() {
return new HDWalletProvider(mnemonicKeyValue, `https://ropsten.infura.io/${infuraKeyValue}`, DEFAULT_ADDRESS_INDEX, addressCountValue);
},
gas: gasKeyValue,
gasPrice: web3.utils.toWei(gasPriceKeyValue, "gwei"),
network_id: "3",
},
infuraMainnet: {
provider: function () {
return new HDWalletProvider(mnemonicKeyValue, `https://mainnet.infura.io/${infuraKeyValue}`, DEFAULT_ADDRESS_INDEX, addressCountValue);
},
gas: gasKeyValue,
gasPrice: web3.utils.toWei(gasPriceKeyValue, "gwei"),
network_id: "1",
},
infuraNet: {
provider: function () {
return new HDWalletProvider(mnemonicKeyValue, `https://infuranet.infura.io/${infuraKeyValue}`, DEFAULT_ADDRESS_INDEX, addressCountValue);
},
gas: gasKeyValue,
gasPrice: web3.utils.toWei(gasPriceKeyValue, "gwei"),
network_id: "2",
}
}
};