i'm testing my smart contract on remix with local ganache cli, when i try to test case that doesn't satisfy a require on the SC i correctly receive message "transact to Contract.function errored: VM Exception while processing transaction: revert {errorMessage}" and the transaction is not executed.

But when i try to do the same test by running a geth node localy i don't have the same behavior, the transaction is submitted and mined, with status 0x0.

This is tricky because the transaction is made, i spend gas and i can't catch immediately the error, as the require method should be able to do.

Thanks in advance

  • We'd need more information about how you're doing your testing to help. One guess: you're sending the transaction to the wrong address in the case of geth. If there's no code at the address you're sending to, the transaction will succeed.
    – user19510
    Mar 28, 2019 at 14:14

1 Answer 1


This is how transactions work in Ethereum. Reverted transaction are still included into blocks and still consume gas (in some case even more gas than successful transactions). Though all ether transfers and all smart contract state changes made by such transactions are reverted, and all log records output by then are dropped.

This is because miner, when he chooses transaction to be evaluated, does not know whether this transaction will succeed or fail. Once miner executed failed transaction, he already spent his resources on this, and thus ought to be rewarded by collecting gas spend by the transaction. As long as miner is only eligible to collect gas for transactions he included into blocks he mined, miners are including failed transactions into blocks.

  • This doesn't explain the different behavior between local Ganache and local Geth. Mar 28, 2019 at 10:15
  • @Mikhail Vladimirov so the only way i have to prevent sending a potentially bad transaction is to put further backend validations before trying transaction? at this point using requires in your smart contract seems usless, if them don't prevent or forecast the failure of a transaction
    – spawn85
    Mar 28, 2019 at 10:19
  • Requires in smart contract are to protect state and assets of the smart contract, not to protect users from spending gas on failed transactions. You may protect yourself from sending failed transactions by calling web3.eth.estimateGas before sending transaction. Mar 28, 2019 at 10:23
  • @spawn85: I know what the difference is, I noted that this answer doesn't explain the difference! Mar 28, 2019 at 10:29
  • @goodvibration very sorry i've understood lately that your comment was referred to mikhail's answer and infact i've quickly removed my useless comment towards you :D
    – spawn85
    Mar 28, 2019 at 10:51

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.