I presume a typical case of smart contract use is purchasing tokens from a smart contract using Metamask. If the contract is at all complex (such as a tiered pricing sale with various caps) and a request to purchase tokens fails - for instance due to exceeding some cap - the user only knows that it has failed, and otherwise has no clue about what caused the failure. If they call the support staff of the company that owns the contract the support staff will likely be similarly in the dark. I totally disagree with the sentiment "fail early and hard -- without any logged event". I wholly support "fail early and hard, but leave tracks." Is this simply beyond the capability of the EVM? There is a failed transaction record present after a failure. Why can't it contain a log from the operation that failed? I must be missing some key point about the way logging "works" (or doesn't)...


There have been a few EIP attempts to add return data/revert reason to the receipt generated from a transaction, but there has been no consensus on how to fairly and safely charge for the data returned, so of course it hasn't been added in a fork. Since reversion reverts everything, you of course can't fetch return data.

An approach that could be used (I don't know if anyone has used it thus far) is to have a top level "error handling contract", essentially it's a proxy that catches all errors and logs an event of the reversion with the revert reason. Of course you lose the original record of msg.sender since the error handler is called.

  • Thanks. I hadn't thought of the gas implications, and how revert error logging could be subverted as a communication tool. A general approach would be to charge for all logging, based on number of bytes logged - regardless of whether the request reverted. But if event output is disposed as part of the reverted state (which still seems wrong to me) there is no simple solution - except check for all possible legitimate failures in a front end dApp. – Stokens Support Nov 2 '18 at 20:11

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.