Skip to main content

Does a failing `require` condition cause emitted events to be reverted too?

Consider the following contrived contract function:

function submitOffer(uint256 foo) public payable {
    emit MyEvent(foo);
    // then later...
    require(foo > 10, "Foo must be greater than 10");
}

This function emits an event on the first line, then later checks some require condition. If the condition fails, any state changes are reverted. Will this cause the event to be "reverted" (or never actually emitted) as well? I assume the answer is yes because the transaction will never actually get included in a block, but is there something I'm not considering?

dalton_c
  • 497
  • 2
  • 17