forked from AztecProtocol/aztec-v1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
truffle.js
59 lines (53 loc) · 2.02 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
const Wallet = require('ethereumjs-wallet');
const { toWei, toHex } = require('web3-utils');
const NonceTrackerSubprovider = require('web3-provider-engine/subproviders/nonce-tracker');
const WalletProvider = require('truffle-wallet-provider');
// when deploying to a non-development network, add the private key of wallet being used into 'accounts.json'
const accounts = require('./accounts');
const keys = accounts.keys || [{ public: '', private: '' }];
const wallet = Wallet.fromPrivateKey(Buffer.from(keys[0].private.slice(2), 'hex'));
function createProvider(infuraUrl) {
return () => {
const hdWallet = new WalletProvider(wallet, infuraUrl);
const nonceTracker = new NonceTrackerSubprovider();
// eslint-disable-next-line no-underscore-dangle
hdWallet.engine._providers.unshift(nonceTracker);
nonceTracker.setEngine(hdWallet.engine);
return hdWallet;
};
}
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
networks: {
development: {
host: '127.0.0.1',
port: 8545, // default port for ganachi-cli
network_id: '*', // Match any network id
},
rinkeby: {
provider: createProvider('https://rinkeby.infura.io'),
gas: 4600000,
gasPrice: toHex(toWei('10', 'gwei')),
network_id: '4',
},
mainnet: {
provider: createProvider('https://mainnet.infura.io'),
gas: 6000000,
gasPrice: toHex(toWei('10', 'gwei')),
network_id: '1',
},
ropsten: {
provider: createProvider('https://ropsten.infura.io'),
gas: 4600000,
gasPrice: toHex(toWei('10', 'gwei')),
network_id: '3',
},
kovan: {
provider: createProvider('https://kovan.infura.io'),
gas: 4600000,
gasPrice: toHex(toWei('10', 'gwei')),
network_id: '42',
},
},
};