0

example:

 function proceed() returns (bool success) {

if (msg.sender != owner) return false;

        return important_function();
    }

So important_function shouldn't be reached if msg.sender isn't owner (condition above returns false). This will give bad jump dest or revert, correct? Thanx!

1 Answer 1

3

Does returning false prevent bool function from further execution in Solidity?

Returning any value prevents any function in (probably) every language from further execution.

This will give bad jump dest or revert, correct?

No, not correct:

  • revert and require(<an expression which evaluates to false>) will revert the transaction with a REVERT opcode
  • assert(<an expression which evaluates to false>) and a few other scenarios (such as accessing an array at an illegal index) will revert the transaction with an INVALID opcode
  • return false will NOT revert the transaction

Your Answer

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

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