Let's suppose this solidity function:

   function myfunction() external {
      emit myevent("hello");

As you can see, the function fires an event.

In some cases, the function will revert a few lines later.

In this case, i will see a failed transaction in the blockchain (with a blockchain explorer). This is normal.

But My event is not visible in this failed transaction. This is a problem because Events are a kind of log for me and it can be usefull to understand why the transaction failed.

Is there a way to fire an event and be sure it will apears in the transaction, even if it fails.

If not, is there a way to "log" some informations with another way than events.

Thanks a lot

1 Answer 1



You can't see the events because the transactions failed and failed transactions don't do anything.

But ...

By popular demand, revert, require and assert can have a reason and the reason bubbles up to a level where it can be displayed by truffle, Remix, etc., in dev and parsed in production. Most users will not have the tools to read it but failed transactions on mainnet can be explored on Etherscan and the reason will be there.

For example:

revert("Step two decided it was time to abort the mission.");

Hope it helps.

Your Answer

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

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