/
truffle-config.js
87 lines (83 loc) · 2.33 KB
/
truffle-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
// Import babel for ES6 support
require('babel-register')({
presets: [
['env', {
'targets': {
'node': '8.0'
}
}]
]
})
require('babel-polyfill')
const HDWalletProvider = require('truffle-hdwallet-provider')
const web3 = require('web3')
const getEnv = env => {
const value = process.env[env]
if (typeof value === 'undefined') {
console.error(`${env} has not been set.`)
}
return value
}
let ENABLE_OPTIMIZER = true
if (getEnv('ENABLE_OPTIMIZER') === 'false') ENABLE_OPTIMIZER = false
// Values must be set in calling environment
// Consult @hareeshnagaraj for details
const privateKey = getEnv('ETH_WALLET_PRIVATE_KEY')
const liveNetwork = getEnv('ETH_LIVE_NETWORK')
const liveNetworkId = getEnv('ETH_LIVE_NETWORK_ID')
const solc = {
// 0.5.16 is latest 0.5.x version
// cannot use 0.6.x due to openzeppelin dependency, which are only 0.5.x compatible
version: '0.5.16',
parser: 'solcjs', // Leverages solc-js purely for speedy parsing
settings: {
evmVersion: 'istanbul', // istanbul is latest stable, and default setting
}
}
if (ENABLE_OPTIMIZER) {
solc.settings.optimizer = {
enabled: true,
runs: 200, // 200 is default value
details: {
orderLiterals: true,
deduplicate: true,
cse: true,
constantOptimizer: true,
yul: false // disabled as Yul optimizer is still experimental in 0.5.x
}
}
}
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
networks: {
production: {
provider: () => new HDWalletProvider(privateKey, liveNetwork),
network_id: liveNetworkId,
gasPrice: web3.utils.toWei('10', 'gwei')
},
staging: {
provider: () => new HDWalletProvider(privateKey, liveNetwork),
network_id: liveNetworkId,
gasPrice: web3.utils.toWei('20', 'gwei')
},
development: {
host: '127.0.0.1', // Localhost (default: none)
port: 8546, // Standard Ethereum port (default: none)
network_id: '*' // Any network (default: none)
},
test_local: {
host: '127.0.0.1',
port: 8556,
network_id: '*'
}
},
// https://solidity.readthedocs.io/en/develop/using-the-compiler.html#input-description
compilers: {
solc: solc
},
mocha: {
enableTimeouts: false
},
plugins: ['solidity-coverage']
}