...by Daniel Szego
"On a long enough timeline we will all become Satoshi Nakamoto.."
Daniel Szego

Thursday, December 28, 2017

Solidity and Truffle Tips and Tricks - gas limit, gas exceptions

If you reach different gas limits during the development and testing your contract and you get different exceptions like out of gas exception or gas limit exceeded, you can do the following things.
- configure the given gas explicitly at the contract creation or at the function execution, like:  

testContract.functionCall(_functionParameter, {gas:4700000});

- or configure the block gas limit in the truffle environment to your testRPC by modifying the truffle.js configuration file and adding explicit block gas limit, like:

  networks: {
    develop: {
      host: "localhost",
      port: 9545,
      network_id: "*",
      gas: 4700000

Note however that the block gas limit on the live network is around 4700000 at the moment, so truffle at this current release do not let you go above this parameter.