2

What happens if one uses Checks-Effects-Interactions Pattern and the gas runs out before the last line of the code in the contract can be reached, i.e., the last line is to interact with another contract and/or making an external call.

The resultant state is an incorrect state as the contract execution is incomplete. Would the use of revert() work?

What if the revert line is never reached as well?

1 Answer 1

2

You don't need to worry about that. If the transaction runs out of gas, it is reverted as a whole. That means, as far as your smart contract is concerned, it will be like the transaction never happened

2
  • Thanks. To see if i understand you correctly, it reverts the whole transaction call? Pretty similar to a 2 phase commit
    – Nathan Aw
    Commented Jul 31, 2018 at 0:33
  • Yes, the whole transaction is reverted
    – Henk
    Commented Jul 31, 2018 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.