Search code examples
ethereumsolidity

Warning! Error encountered during contract execution [Reverted]


1)What can cause this message error to appear while depositing ERC20 on allowance? "Warning! Error encountered during contract execution [Reverted]"

2)Also from what I noticed while debugging it has something to do with 'require(b <= a)' while depositing. I haven't seen it with tokens using 'assert' instead of 'require' for their SafeMath, would using 'assert' display different error message for the same problem? Or I'm just missing something?


Solution

  • What can cause this message error to appear while depositing ERC20 on allowance? "Warning! Error encountered during contract execution [Reverted]"

    It depends on the actual contract implementation. Revert happens when a contract produces an invalid opcode, most likely as a result of failed validation in require(), assert() or throws the exception directly using throw().

    Most likely, it's going to fail a validation whether the transaction sender is allowed to send this amount of the owner's tokens, or whether the owner has this amount available.


    Would using 'assert' display different error message for the same problem?

    assert() doesn't allow for custom error message.

    The "Warning! Error encountered..." is a message from your web3, not the contract itself. It's going to display the same message when the transaction reverts - no matter whether it reverted because of assert() or require().