-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtruffle.js.default
67 lines (57 loc) · 1.44 KB
/
truffle.js.default
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
const WalletProvider = require('truffle-wallet-provider')
const Wallet = require('ethereumjs-wallet')
const {
HOST,
PORT,
NETWORK_ID,
TRUFFLE_GAS,
TRUFFLE_GAS_PRICE,
INFURA_ACCESS_TOKEN,
} = process.env
const accounts = require('./data/ganache-cli-accounts.json')
const development = {
from : accounts[0][1],
host : HOST || '127.0.0.1',
port : PORT || 8545,
gas : TRUFFLE_GAS || 3 * 10**6,
gasPrice : TRUFFLE_GAS_PRICE || 20 * 10**9,
network_id : NETWORK_ID || 5777,
}
const infuraNetworks = ! INFURA_ACCESS_TOKEN ?
{}:
['ropsten', 'rinkeby', 'kovan', 'mainnet'].reduce(
(result, network) => {
const envForPrivateKey = `${network.toUpperCase()}_PRIVATE_KEY`
const privateKeyString = process.env[envForPrivateKey]
if (privateKeyString) {
const privateKey = Buffer.from(
privateKeyString.replace('0x', ''),
'hex'
)
const wallet = Wallet.fromPrivateKey(privateKey)
const provider = new WalletProvider(
wallet,
`https://${network}.infura.io/${INFURA_ACCESS_TOKEN}`
)
result[network] = {
...development,
provider
}
}
return result
},
{}
)
module.exports = {
rpc: development,
networks: {
...infuraNetworks,
development,
},
solc: {
optimizer: {
enabled: true,
runs: 200
}
}
}