1

I have code which transfer the ether to another address. And below that, I have require() condition will be failing. so will that execute the ether transfer or it will not transfer?

function ethTransfer(){

  someAddress.transfer(amount);

  require((1==5), 'error');   // ever reverting!!!

}

Any idea will be helpful. Thanks

  • 1
    Does this code even compile??? 1=5 is an assignment, not a boolean expression. Also, address is a key word, so address.transfer doesn't look like something which can compile. Please post a working example. Side note: instead of asking the question, you could simply run your code and check the balance of the account. – goodvibration Feb 18 '19 at 8:31
  • 1
    I was thinking exactly the same. However, I think perhaps what is actually being asked is more of a conceptual question, rather than a code question: i.e. If a transfer has already been made, do failures further down the codepath cause that transfer to be reverted or not? – Richard Horrocks Feb 18 '19 at 12:38
3

Yes. If you revert within a call frame, all previous actions in that call frame (including sub-call frames) will be reverted.

|improve this answer|||||
0

A part the coding errors in the example code, your question is clear.

Answer: yes they will be transferred executing your transfer instruction. When your require shall be hit, it will revert all done before and the transferring as well.

|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.