2

This transaction: https://etherscan.io/tx/0xfcf6acee992a6562aeb641fe830b93a6e6c3be9080eb3842909137824d6a7881, has an odd message that I first noticed today:

Although one or more errors occurred [Out of gas] contract execution completed

If I retrieve the transaction using EtherScan's API, EtherScan does not report it as an error transaction (and, I don't think it was an error transaction). If I look at the traces of the transaction by pulling them from a local node, many of the traces report "out of gas".

I was under the impression that if any part of the transaction ran out of gas, the entire transaction would revert.

Question: How is this possible? What happened here? Is this common?

Note: I will be more likely to accept the answer if you provide simple, Solidity example of how this can happen.

1

Yes, this can happen if a CALL is made to another contract. Only a portion of gas is forwarded, and so that call can run out of gas. If the "parent" doesn't revert on the CALL failure, then the main transaction can succeed while the call fails due to an out of gas error.

Here's one example of how that can happen. (Call A.forward(addressOfB).)

pragma solidity ^0.4.21;

contract A {
    function forward(address to) public payable {
        to.send(msg.value); // only forwards 2300 gas
                            // returns false due to out of gas error
    }
}

contract B {
    uint256 foo;

    function () public payable {
        foo = 3; // not enough gas to SSTORE
    }
}
  • Thanks. So, the transaction’s status field would be 1 (success), but the trace would have an “out of gas”. Is that right? – Thomas Jay Rush Mar 19 '18 at 10:37
  • I believe that's correct. – smarx Mar 19 '18 at 10:46

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.