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?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityI 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?
Try manually setting the gas limit in your truffle.js file for your development network:
development : {
...
gas: 4612388
}
ganache-cli
is 6721975.
– Paul Razvan Berg
Jan 17 '19 at 12:04
which truffle
code /home/user/.nvm/versions/node/v8.11.1/bin/truffle
crtl+f 6721975
– Barrard
Jan 22 '19 at 12:48
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.
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
I solved it and now can run mocha ganache tests without truffle. Solidity Exceeds block gas limit during Mocha Tests with Ganache-cli