Skip to content

Instantly share code, notes, and snippets.

@maxaleks
Created November 28, 2018 16:39
Show Gist options
  • Save maxaleks/df5178900e2355d8f14c0ddca3789970 to your computer and use it in GitHub Desktop.
Save maxaleks/df5178900e2355d8f14c0ddca3789970 to your computer and use it in GitHub Desktop.
const dotenv = require('dotenv');
const { toWei } = require('web3-utils');
const HDWalletProvider = require('truffle-hdwallet-provider');
const NonceTrackerSubprovider = require('web3-provider-engine/subproviders/nonce-tracker');
const Web3 = require('web3');
dotenv.config();
dotenv.config({ path: '.env.local' });
const getProvider = urlOrProvider => () => {
const wallet = new HDWalletProvider(process.env.MNEMONIC, urlOrProvider);
const nonceTracker = new NonceTrackerSubprovider();
wallet.engine._providers.unshift(nonceTracker);
nonceTracker.setEngine(wallet.engine);
return wallet;
};
function infuraWSProvider(network) {
const url = `wss://${network}.infura.io/ws/v3/${process.env.INFURA_PROJECT_ID}`;
return new Web3.providers.WebsocketProvider(url);
}
module.exports = {
contracts_build_directory: `${__dirname}/build_contracts`,
networks: {
development: {
host: 'localhost',
port: 7545,
network_id: '*',
gasPrice: toWei('10', 'gwei'),
websockets: true,
},
live: {
provider: getProvider(infuraWSProvider('mainnet')),
network_id: 1,
gasPrice: toWei('10', 'gwei'),
websockets: true,
timeoutBlocks: 200,
skipDryRun: true,
},
kovan: {
provider: getProvider(infuraWSProvider('kovan')),
network_id: 42,
gasPrice: toWei('4', 'gwei'),
websockets: true,
timeoutBlocks: 200,
skipDryRun: true,
},
rinkeby: {
provider: getProvider(infuraWSProvider('rinkeby')),
network_id: 4,
gasPrice: toWei('10', 'gwei'),
websockets: true,
timeoutBlocks: 200,
skipDryRun: true,
},
},
compilers: {
solc: {
version: '0.4.25',
optimizer: {
enabled: true,
runs: 200
}
},
},
mocha: {
enableTimeouts: false
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment