Tired of getting outputs like

"Warning! Error encountered during contract execution [Out of gas]"

and having to specify gas limit on every smart contract call like

sc.endpoint(parameters, {gas:1000000});

I would like to know if there is any web3 command similar to

web3.eth.defaultAccount = "...";

capable of define a new limit to gas consumed on my next transactions.

Variable web3.eth.gasLimit seems not to exist...



tl;dr You can't do this with web3 .. yet. You can track progress of the proposal to improve web3, and add improvements such as promises and defaults in this ticket: EIP68.

However, you can do something similar on the contract level with truffle-artifactor (formerly called ether-pudding):

var myContract = MyContract.at("0x1234...");
  gasLimit: "100000"

Or alternatively, the following is equivalent:

var myContract = MyContract.at("0x1234...", {gasLimit: "10000"});
| improve this answer | |

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.