-
Notifications
You must be signed in to change notification settings - Fork 0
/
truffle-config.js
345 lines (322 loc) · 13.8 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
/**
* Use this file to configure your truffle project. It's seeded with some
* common settings for different networks and features like migrations,
* compilation and testing. Uncomment the ones you need or modify
* them to suit your project as necessary.
*
* More information about configuration can be found at:
*
* truffleframework.com/docs/advanced/configuration
*
* To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider)
* to sign your transactions before they're sent to a remote public node. Infura accounts
* are available for free at: infura.io/register.
*
* You'll also need a mnemonic - the twelve word phrase the wallet uses to generate
* public/private key pairs. If you're publishing your code to GitHub make sure you load this
* phrase from a file you've .gitignored so it doesn't accidentally become public.
*
*/
// this is a copy from the superfluid repository
const HDWalletProvider = require("@truffle/hdwallet-provider");
try {
require("dotenv").config();
} catch (error) {
console.error(
"Loading .env file failed. Things will likely fail. You may want to copy .env.template and create a new one."
);
}
//
// This is a hack to resolve that HDWallet doesn't work with openethereum (xdai & kovan)
//
// Related issues:
// - https://github.com/trufflesuite/truffle/issues/3182
// - https://github.com/openethereum/parity-ethereum/issues/11824
// - https://github.com/MetaMask/web3-provider-engine/issues/311
function createProviderForOpenEthereum(url) {
let provider;
const Web3WsProvider = require("web3-providers-ws");
if (url.startsWith("ws:") || url.startsWith("wss:")) {
provider = new Web3WsProvider(url);
// apply the skipCache hack
const origSend = provider.__proto__.send;
provider.__proto__.send = function (payload, callback) {
delete payload.skipCache;
origSend.call(provider, payload, callback);
};
} else {
// let hdwallet provider handle the url directly
provider = url;
}
return provider;
}
module.exports = {
plugins: [
//"truffle-security",
"solidity-coverage",
"truffle-plugin-verify",
],
/**
* Networks define how you connect to your ethereum client and let you set the
* defaults web3 uses to send transactions. If you don't specify one truffle
* will spin up a development blockchain for you on port 9545 when you
* run `develop` or `test`. You can ask a truffle command to use a specific
* network from the command line, e.g
*
* $ truffle test --network <network-name>
*/
networks: {
// Useful for testing. The `development` name is special - truffle uses it by default
// if it's defined here and no other network is specified at the command line.
// You should run a client (like ganache-cli, geth or parity) in a separate terminal
// tab if you use this network and you must also set the `host`, `port` and `network_id`
// options below to some value.
// NOTE: networks with provider init not yet changed to the format expected by hdwallet-provider 1.4
// are commented out.
/*
rinkeby: {
provider: () =>
new HDWalletProvider(
process.env.RINKEBY_MNEMONIC,
process.env.RINKEBY_PROVIDER_URL,
0, //address_index
10, // num_addresses
true // shareNonce
),
network_id: 4,
gas: 8e6,
gasPrice: 10e9, // 10 GWEI
//confirmations: 6, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 50, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: false, // Skip dry run before migrations? (default: false for public nets )
},
ropsten: {
provider: () =>
new HDWalletProvider(
process.env.ROPSTEN_MNEMONIC,
process.env.ROPSTEN_PROVIDER_URL,
0, //address_index
10, // num_addresses
true // shareNonce
),
network_id: 3,
gas: 8e6,
gasPrice: 10e9, // 10 GWEI
//confirmations: 6, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 50, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: false, // Skip dry run before migrations? (default: false for public nets )
},
goerli: {
provider: () =>
new HDWalletProvider(
process.env.GOERLI_MNEMONIC,
process.env.GOERLI_PROVIDER_URL,
0, //address_index
10, // num_addresses
true // shareNonce
),
network_id: 5,
gas: 8e6,
gasPrice: +process.env.GOERLI_GAS_PRICE || 100e9, // 100 GWEI, goerli is busy!
//confirmations: 6, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 50, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: false, // Skip dry run before migrations? (default: false for public nets )
},
*/
kovan: {
provider: () => {
return new HDWalletProvider({
mnemonic: process.env.KOVAN_MNEMONIC,
providerOrUrl: createProviderForOpenEthereum(
process.env.KOVAN_PROVIDER_URL
),
numberOfAddresses: 10,
shareNonce: true,
chainId: 42
})
},
network_id: 42,
gas: 8e6,
gasPrice: +process.env.KOVAN_GAS_PRICE || 10e9,
//confirmations: 6, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 50, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: false, // Skip dry run before migrations? (default: false for public nets )
},
/*
arbitrum: {
provider: function () {
const wrapProvider = require("arb-ethers-web3-bridge")
.wrapProvider;
// return wrapped provider:
return wrapProvider(
//new HDWalletProvider(process.env.ARBITRUM_MNEMONIC, "wss://kovan3.arbitrum.io/ws")
new HDWalletProvider(
process.env.ARBITRUM_MNEMONIC,
process.env.ARBITRUM_PROVIDER_URL
)
);
},
network_id: "*",
gas: 1e9, // arbgas is a different beast, 1G gas is normal
gasPrice: 0,
},
*/
xdai: {
provider: () => {
return new HDWalletProvider({
mnemonic: process.env.XDAI_MNEMONIC,
privateKeys: [process.env.XDAI_PRIVKEY],
providerOrUrl: createProviderForOpenEthereum(
process.env.XDAI_PROVIDER_URL
),
numberOfAddresses: 10,
shareNonce: true,
chainId: 100
})
},
network_id: 0x64,
gas: 8e6,
gasPrice: +process.env.XDAI_GAS_PRICE || 1e9,
//confirmations: 6, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 50, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: false, // Skip dry run before migrations? (default: false for public nets )
},
matic: {
provider: () => {
return new HDWalletProvider({
mnemonic: process.env.MATIC_MNEMONIC,
privateKeys: [process.env.MATIC_PRIVKEY],
providerOrUrl: createProviderForOpenEthereum(
process.env.MATIC_PROVIDER_URL
),
numberOfAddresses: 10,
shareNonce: true,
chainId: 137
})
},
network_id: 137,
gas: 8e6,
gasPrice: +process.env.MATIC_GAS_PRICE || 1e9,
//confirmations: 6, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 50, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: false, // Skip dry run before migrations? (default: false for public nets )
},
/*
mumbai: {
provider: () =>
new HDWalletProvider(
process.env.MUMBAI_MNEMONIC,
process.env.MUMBAI_PROVIDER_URL,
0, //address_index
10, // num_addresses
true // shareNonce
),
network_id: 80001,
gas: 8e6,
gasPrice: +process.env.MUMBAI_GAS_PRICE || 1e9, // default 1 gwei
//confirmations: 6, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 50, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: false, // Skip dry run before migrations? (default: false for public nets )
},
artis_tau1: {
provider: () =>
new HDWalletProvider(
process.env.ARTIS_MNEMONIC,
process.env.ARTIS_PROVIDER_URL,
0, //address_index
10, // num_addresses
true // shareNonce
),
network_id: 0x03c401, // artis tau1 network
gas: 8e6,
gasPrice: +process.env.ARTIS_GAS_PRICE || 1e9, // default 1 gwei
//confirmations: 6, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 50, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: false, // Skip dry run before migrations? (default: false for public nets )
},
*/
mainnet: {
provider: () => {
return new HDWalletProvider({
mnemonic: process.env.MAINNET_MNEMONIC,
privateKeys: [process.env.MAINNET_PRIVKEY],
providerOrUrl: createProviderForOpenEthereum(
process.env.MAINNET_PROVIDER_URL
),
numberOfAddresses: 10,
shareNonce: true,
chainId: 1
})
},
network_id: 1, // mainnet's id
gas: 8e6,
gasPrice: +process.env.MAINNET_GAS_PRICE || 1e9, // default 1 gwei
//confirmations: 6, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 50, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: false, // Skip dry run before migrations? (default: false for public nets )
},
coverage: {
host: "localhost",
network_id: "*",
port: 8555, // <-- If you change this, also set the port option in .solcover.js.
gas: 0xfffffffffff, // <-- Use this high gas value
gasPrice: 0x01, // <-- Use this low gas price
},
ganache: {
host: "127.0.0.1",
network_id: "*",
port: process.env.GANACHE_PORT || 8545,
},
// Another network with more advanced options...
// advanced: {
// port: 8777, // Custom port
// network_id: 1342, // Custom network
// gas: 8500000, // Gas sent with each transaction (default: ~6700000)
// gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei)
// from: <address>, // Account to send txs from (default: accounts[0])
// websockets: true // Enable EventEmitter interface for web3 (default: false)
// },
// Useful for deploying to a public network.
// Note: It's important to wrap the provider as a function.
// ropsten: {
// provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`),
// network_id: 3, // Ropsten's id
// gas: 5500000, // Ropsten has a lower block limit than mainnet
// confirmations: 2, // # of confs to wait between deployments. (default: 0)
// timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
// skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
// },
// Useful for private networks
// private: {
// provider: () => new HDWalletProvider(mnemonic, `https://network.io`),
// network_id: 2111, // This network is yours, in the cloud.
// production: true // Treats this network as if it was a public net. (default: false)
// }
},
// Set default mocha options here, use special reporters etc.
//mocha: {
// // timeout: 100000
// reporter: "eth-gas-reporter",
// reporterOptions: {
// noColors: true,
// outputFile: "build/eth-gas-report.txt"
// }
//},
// Configure your compilers
compilers: {
solc: {
version: "0.7.6", // Fetch exact version from solc-bin (default: truffle's version)
settings: {
// See the solidity docs for advice about optimization and evmVersion
optimizer: {
enabled: true,
runs: 200,
},
// evmVersion: use default
},
},
},
api_keys: {
etherscan: process.env.ETHERSCAN_API_KEY,
},
};