I was able to deploy the contract successfully to Kovan with gas limit 350000.

When i set the gas in truffle.js to 500000 for deployment to Mainnet, i get the below error: Error: Transaction cost exceeds current gas limit. Limit: 5000, got: 500000. Try decreasing supplied gas.

So i decrease the gas to 5000, i got the error below: Error: Transaction gas is too low. There is not enough gas to cover minimal cost of the transaction (minimal: 498172, got: 5000).

it just won't deploy the contract, how can the Limit is so much lesser than minimal? how to solve this problem?

  • 1
    Try deploying it with web3.js directly: add "web3": "1.0.0-beta.34" to your package.json, rerun npm 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. Sep 16, 2018 at 10:14
  • It seems you have a problem with your node it is not fully synced or it is not syncing to mainnet. Currently the block gas limit is 8M.
    – Ismael
    Sep 16, 2018 at 14:00

1 Answer 1


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])

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
  1. Run deployment MNEMONIC='YOUR SEED' NETWORK=kovan npx truffle migrate --reset --network mnemonic

you can change kovan to mainnet or rinkeby or ropsten

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.