Last active
February 20, 2020 00:54
-
-
Save alexytiger/ff979f2cdd40085b4077073b13765df9 to your computer and use it in GitHub Desktop.
e-book
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const HDWalletProvider = require('@truffle/hdwallet-provider'); | |
const { readFileSync } = require('fs'); | |
const path = require('path'); | |
module.exports = { | |
networks: { | |
ganache: { | |
host: "127.0.0.1", | |
port: 7545, | |
network_id: "*" // matching any network id | |
}, | |
ropsten: { | |
provider: () => { | |
try { | |
const fileContents = | |
readFileSync(path.join(__dirname, 'secret.json'), 'utf8') | |
const data = JSON.parse(fileContents); | |
const privateKey = data.mnemonic; | |
// Your project id, which we copied from Infura.io | |
const infuraProjectId = data.infuraProjectToken; | |
const rpcUrl = `https://ropsten.infura.io/v3/${infuraProjectId}`; | |
const ropstenAccountId = 0; | |
/* | |
If we skip the last argument in the HDWalletProvider constructor, | |
by default, the account in charge of | |
the smart contract deployment will be | |
the first one generated by the mnemonic. | |
If we pass in a specific index, | |
it'll use that address instead (the index is zero-based). | |
*/ | |
// How many addresses in wallet should we unlock? | |
// Note: This is not used for Mainnet - only for Testnet and local deployment. | |
const numAddressesToUnlock = 3 | |
console.log('Configuring truffle to use Mnemonic provider for Ropsten.'); | |
return | |
new HDWalletProvider(privateKey, rpcUrl, ropstenAccountId, numAddressesToUnlock); | |
} catch (err) { | |
console.error('Error', err); | |
} | |
}, | |
network_id: 3, // Ropsten network id | |
//Default gas limit in Truffle is 4712388 (gas limit for Homestead release). | |
// This exceeds Ropsten's limit. Make sure to set a gas limit to 4700000. | |
// Otherwise, you will see the following error. Error: exceeds block gas limit | |
gas: 4700000, | |
}, | |
}, | |
// Configure your compilers | |
compilers: { | |
solc: { | |
// version: "0.5.12", Fetch exact version from solc-bin | |
// (default: truffle's version | |
settings: { | |
optimizer: { | |
enabled: true, | |
runs: 200 | |
}, | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment