1

I have encountered the Exceeds Gas Limit problem back when I was deploying to my local Ganache. I had to refactor my contracts and break it apart to several contracts. I got it to work.

Now, I'm encountering the same when trying to deploy to Ropsten via Infura.

I'm getting the Exceeds Gas Limit even when just deploying Migrations.sol. I have enough gas in my primary account.

My Truffle config is this:

// Allows us to use ES6 in our migrations and tests.
require('babel-register')
var HDWalletProvider = require("truffle-hdwallet-provider");

var infura_apikey = "... ...";
var mnemonic = "... ... ... ...";

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*' // Match any network id
    },
    ropsten: {
      provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/"+infura_apikey),
      network_id: 3
    }
  }
}

Initial Migration JS is standard code.

var Migrations = artifacts.require("./Migrations.sol");

module.exports = function(deployer) {
  deployer.deploy(Migrations, { gas: 4700000, //may be 21000 - 3000000
gasPrice: 20000000000});
};

What am I missing here? It is failing during initial migration.

Using network 'ropsten'.

Setting gas to 4,700,000 seems to be low. (How can this be? This is just the Migrations contract!)

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x6810b697ecf938b94a134ed62865b661dcd5f37ae53bd08dc575b8850de968ef
  Migrations: 0x64e70064a0b59f8d2b789f7cb50e6a9465abaf35
Saving successful migration to network...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
exceeds block gas limit

Setting it to 4,800,000 seems to exceed Ropsten's limit.

Running migration: 1_initial_migration.js   
Deploying Migrations...
Error encountered, bailing. Network state unknown. Review successful
transactions manually. exceeds block gas limit

UPDATE

Eventually I gave up developing on Ropsten, and worked on Rinkeby instead. I didn't have such problems anymore.

1

Your gas is not too low, it is too high

Ethereum block have a total gas limit cap around 4 700 000, meaning that the total of all the transactions contained in the block should not be higher than 4.7 millions. Yours alone is equal to the limit, so it is not likely to be included in the block. Try setting a lower gas limit.

  • 2
    I get the same message when setting gas to 1 million. – Jonas Arcangel Mar 12 '18 at 18:11

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.