-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtruffle.js
59 lines (54 loc) · 1.31 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
require('dotenv').config();
const WalletProvider = require('truffle-wallet-provider')
const Wallet = require('ethereumjs-wallet')
const parsePrivateKey = privateKey => new Buffer(privateKey, "hex")
const getWalle = function (network) {
let wallet;
switch (network) {
case 'ropsten':
let ropstenPrivateKey = parsePrivateKey(process.env.ROPSTEN_PRIVATE_KEY)
wallet = Wallet.fromPrivateKey(ropstenPrivateKey)
break
case 'rinkeby':
let rinkebyPrivateKey = parsePrivateKey(process.env.RINKEBY_PRIVATE_KEY);
wallet = Wallet.fromPrivateKey(rinkebyPrivateKey);
break
default:
break
}
return wallet
}
const infuraProvider = function (network) {
let wallet = getWalle(network)
return new WalletProvider(wallet, `https://${network}.infura.io/`)
}
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
},
ropsten: {
provider: infuraProvider("ropsten"),
gas: 4600000,
gasPrice: 100000000000,
network_id: "3"
},
rinkeby: {
provider: infuraProvider("rinkeby"),
gas: 4600000,
gasPrice: 100000000000,
network_id: "4"
}
},
solc: {
optimizer: {
enabled: true,
runs: 200
}
},
mocha: {
useColors: true
}
};