0

CODE:

(success, ) = contract.call(); // low level call
if (success) {
    // do something
}

// instead of below check, can I just use require(condition)?
if (!condition) {
    revert();
}

Instead of checking the condition and using revert(), can I use require(condition) to ensure the whole tx including the low level calls are reverted?

1 Answer 1

0

The short answer is yes, you can

require() uses the 0xfd opcode to generate an error condition. That is, in the end it calls revert() So the difference is immaterial between the constructs:

if (!condition) {
    revert();
}

и

require(condition);

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.