6

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?

rhlsthrm
  • 425
  • 1
  • 3
  • 11

4 Answers4

5

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

development : {
 ...
 gas: 4612388
}
Howard
  • 421
  • 2
  • 6
5

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.

Billie
  • 133
  • 2
  • 6
2

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

oliver nadj
  • 121
  • 4
1

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

Paul Razvan Berg
  • 17,902
  • 6
  • 73
  • 143
Russo
  • 1,784
  • 1
  • 21
  • 30