1.Use truffle v5
2.Use MNEMONIC phrase and fund the account.
const HDWalletProvider = require('truffle-hdwallet-provider');
const hd = new HDWalletProvider(process.env.MNEMONIC);
console.log('your address ', hd.addresses[0])
process.exit(1)
2.Here is truffle.js config below
const {MNEMONIC, NETWORK} = process.env;
const HDWalletProvider = require('truffle-hdwallet-provider')
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
networks: {
mnemonic: {
provider: () => new HDWalletProvider(MNEMONIC, `https://${NETWORK}.infura.io`),
network_id: '*',
gas: 6500000, // Default gas to send per transaction
gasPrice: 1000000000, // 10 gwei (default: 20 gwei)
confirmations: 0, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: false // Skip dry run before migrations? (default: false for public nets )
},
},
compilers: {
solc: {
settings: {
optimizer: {
enabled: true, // Default: false
runs: 200 // Default: 200
},
}
}
}
};
- Run deployment
MNEMONIC='YOUR SEED' NETWORK=kovan npx truffle migrate --reset --network mnemonic
you can change kovan
to mainnet
or rinkeby
or ropsten
"web3": "1.0.0-beta.34"
to yourpackage.json
, rerunnpm install
, and keep in mind that since Truffle still relies on web3.js v0.x, the API is slightly (or very) different. I wrote an answer to a similar question here. You can follow the exact procedure described in that answer.