3

I can deploy my contract on Remix (Javascript VM and Rinkeby), but if I try to use truffle develop and migrate, I am getting an error: Error: Exceeds block gas limit. The gas used in Remix is 3585084.

How can I make it work in truffle?

3

Try manually setting the gas limit in your truffle.js file for your development network:

development : {
 ...
 gas: 4612388
}
  • 1
    This works, but there is still another limit that seems hardcoded around 6700000 gas. – rhlsthrm Mar 5 '18 at 16:49
  • 1
    As of Jan 2019, the hardcoded gas limit in ganache-cli is 6721975. – Paul Razvan Berg Jan 17 at 12:04
  • which truffle code /home/user/.nvm/versions/node/v8.11.1/bin/truffle crtl+f 6721975 – Barrard Jan 22 at 12:48
4

The gas parameter in truffle.js is NOT the chain's block gas limit. It means maximum to pay for deploys.

So doesn't matter how big you set the number as long as a actual gas required is larger than the hardcoded chain block gas limit you will get the same error again and again!

Here's my answer:

Truffle contract deployment either exceeds block gas limit or out of gas

Hope it helps.

1

You can check your maximum gas limit with web3.eth.getBlock("pending").gasLimit command in truffle develop console.

Example:

truffle(develop)> web3.eth.getBlock("pending").gasLimit
6721975

That is the maximum number you can set in truffle.js

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      gas: "6721975",
      network_id: "*" // Match any network id
    }
  }
};

Source: https://github.com/trufflesuite/truffle/issues/271#issuecomment-341952559

1

I solved it and now can run mocha ganache tests without truffle. Solidity Exceeds block gas limit during Mocha Tests with Ganache-cli

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.