-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtruffle.js
102 lines (93 loc) · 3.6 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* NB: since truffle-hdwallet-provider 0.0.5 you must wrap HDWallet providers in a
* function when declaring them. Failure to do so will cause commands to hang. ex:
* ```
* mainnet: {
* provider: function() {
* return new HDWalletProvider(mnemonic, 'https://mainnet.infura.io/<infura-key>')
* },
* network_id: '1',
* gas: 4500000,
* gasPrice: 10000000000,
* },
*/
require('dotenv').config();
const Web3 = require("web3");
const DEFAULT_GAS_WEI = 4600000;
const DEFAULT_ADDRESS_COUNT = 10;
const DEFAULT_ADDRESS_INDEX = 0;
const DEFAULT_GAS_GWEI_PRICE = "20";
const web3 = new Web3();
const HDWalletProvider = require("truffle-hdwallet-provider");
var ganache = require("ganache-cli");
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: "localhost",
port: 8545,
network_id: "*",
provider: function() {
return new HDWalletProvider(
'concert load couple harbor equip island argue ramp clarify fence smart topic',
`http://localhost:8545`,
DEFAULT_ADDRESS_INDEX,
addressCountValue
);
},
},
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",
}
}
};