0

Consider this imaginary solidity function:

function doSomething(){
   msg.sender.transfer(1000);
   a += 1;
   require(false);
}

According to the docs variable a will not be incremented by 1 because the require(false) will cause the transaction to revert. My question is: will the 1000 wei transfer occur or not?

  • No, if a transaction is reverted, then it has no effect except to consume the already-used gas. – user19510 Jun 21 '18 at 17:10
1

It won't occur. All the changes will be reverted if the requirement is not fulfilled. In fact, if you try to execute this, for instance, in remix you will get a warning saying that the transaction will fail. If you force the transaction it will be mines but will fail.

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