8

Given that a transaction has

  1. A high enough gas limit for the transaction to succeed
  2. A high enough gas price for it to be mined
  3. No contract calls that throws

Is there any way that transaction can fail?

4 Answers 4

6

If there's enough gas provided, with the necessary gas price, and no contract calls that throw, then it shouldn't fail.

You should also consider the case where even if a large amount of gas is provided, if the contract contains an unbounded loop, some complex computation or recursive calls, it could fail by running out of gas, even if you provide the maximum possible gas limit.

2
  • And the receipt of such transactions(tx runs out of gas) would return "Success" or "0x1"?
    – Ayushya
    Commented Oct 5, 2018 at 11:19
  • Could you take a look at why this transaction is failing? ethereum.stackexchange.com/questions/102668/… -- There are no loops or throws, and there's plenty of gas. Commented Jun 30, 2021 at 18:33
2

I see no possibilities how such transaction could be mined as unsuccessful, i.e. included into block but do not transfer ether. Though there are several possible reasons how such transaction could not be mined at all:

  1. Not enough ether on origination account to perform transfer and pay for gas
  2. Nonce is too high or too low
  3. Signature is incorrect
  4. Transaction gas consumption exceeds block gas limit
2

Even if there's no explicit throw in the contract, the transaction may still attempt to perform invalid runtime operation like division by zero, for example, or out of bounds array access. Both would result in FAILure.

1
  • Thank you! It is clear that an error in my smart contract is due to array out of bounds! Commented Jun 30, 2021 at 18:44
0

A possibility would be to 'double submit' a transaction. If one were to submit a transaction to the ethereum network, with sufficient gas limit, gas price, no contract call errors, etc (a perfect transaction) and THEN submit another 'perfect' transaction from the same account, with the SAME nonce as the previously sent transaction, one of these transactions will fail.

This is a property of the ethereum network, that all transactions from an account must occur in sequential order, increasing by one, every transaction. This is often used to 'cancel' a pending 'slow' transaction, one that is taking a long time waiting in a miner pool for inclusion into a block. Submitting a transaction, at the same nonce as the pending with a high gas price incentivizes miners to include this transaction. And consequently on transaction inclusion, will invalidate the pending 'slow' transaction

1
  • 1
    In case of a duplicate nonce only one transaction may make it to the blockchain (and succeed or fail as a result), the other one will not fail - it won't even make it to the blockchain. That's a huge difference. If it fails, the fee is paid still.
    – knaperek
    Commented May 3, 2021 at 13:45

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.