0

I'm using remix to test out a particular contract method (both using the Javascript VM and a local blockchain via Ganache), and get this error for a specific contract method:

function withdrawAll() public payable {
    _totalSupply -= balances[msg.sender];
    balances[msg.sender] = 0;

    Withdrawal(msg.sender, this.balance);

    msg.sender.transfer(this.balance);
}

Using the debugger I see that the execution stops on the balances[msg.sender] = 0 line. The blockchain tells me that 27211 gas was a used, and that there is a Runtime error: out of gas.

Like I mention in the subject though – I provide a gas allowance much larger than this using remix, so I have no idea how to avoid this error. I have also played around with different gas allowances (both smaller and larger).

  • Many times, the network outputs the out of gas error as a generic error. You could ude the debugTraceTransaction in web3 to trace where it throws, and it could provide more help – Hari GTT Psicolabis Mar 5 '18 at 20:08
  • I found that remix debugger sometimes will get confused when doing step by step trace. I see no evident error in your code but is not enough to try to reproduce it. Try commenting/uncommenting lines until you are sure where the error is. Perhaps some uninitialized storage data. – Ismael Mar 6 '18 at 4:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.