1

I send ETH to a smart contract of my own, and it always fail. At etherscan I search the failed transaction and it has this message:

"Value transfer did not complete, most likely as a result of a revert opcode."

It always happens, it's like my code doing all the operations but at the end applying this REVERT OPT CODE. I didn't program any revert opt code at least not concious about that. I'm new to this so I have no idea why this is happening.

Can someone tell me what is a REVERT OPT CODE???

4
  • Check your code : Did someone (your past/bot) call the function that is meant to be called once and branching off? (Your error is pretty common for cryptokitties users competing to buy the cheapest kitty and losing.) Please share contract code for us to be able to help you more.
    – neutral
    Jan 15, 2018 at 21:27
  • hello can you help me with thats problem? Jan 22, 2018 at 20:58
  • Do you have any require() statements in your smart contract? Requires will throw reverts if their requirements are not met.
    – wtk219
    Jan 22, 2018 at 20:59
  • maybe you forgot to declare a payable function or fallback
    – Badr Bellaj
    May 6, 2018 at 13:17

2 Answers 2

1

revert() can happen for a few reasons, other than explicitly saying revert():

  1. require statements will revert when not satisfied. assert statements do the same.

  2. sending ether to a contract without a fallback function, or with a fallback function that uses more than the 2300 gas that is allocated during a transfer, will cause the transfer to revert.

I think in your case it sounds like the second reason. make sure the contract you're transferring to has a fallback function, and that you're not doing anything that requires a lot of gas (ie. saving to storage) in the fallback. fallback functions only receive enough gas from a transfer to log an event.

1
  • 1
    Assert statements will actually run the error opcode, not the revert opcode. The only real difference is that revert doesn't eat all gas and error will.
    – natewelch_
    Nov 18, 2018 at 2:26
1

“Revert op code” means any EVM (that is the virtual machine that execute your code or the code of the applications you use on the Ethereum network) instruction that give to it the command to erase and nullify the last elaborations, made by the current task, “reverting” the blockchain status to that before your code run.

That is if you make some operations on the blockchain (mint, transfer, read, write, etc) but a revert op code is encountered, all is erased and the blockchain remain that it was before you tried to change (by your code).

In your case: some operations you do are wrong for same reasons (permissions not correct, money not available, address not correct) and the transaction aborts.

Often this happens if you give not enough gas to the transaction: when the gas is consumed, a revert code is executed.

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.