0

According to this highest upvoted answer, "but still include it in the blockchain as a "failed transaction"... What is meant by the term "gas"?

1

Why

A transaction may succeed or fail depending on when/where it was mined. The initial state matters and that is only knowable when the transaction exists in unambiguous transaction order.

Consider getting paid on the same day rent is due and your landlord has a post-dated check. The order of events, the transaction order, may be the determining factor (if your available balance is less than the value of the check).

Did you have sufficient funds when they cashed the check? Did the check bounce before necessary funds were received?

A signed transaction is like a signed check. We do not know if it will succeed or not until we try. The result will depend on what came before. In blockchain, as with checks, it is possible to avoid failure by only signing transactions that should clear. It is also possible to front-run pending transactions perchance to create the conditions that will help a pending transaction succeed even if it was set to fail given conditions at the time it was signed.

The blockchain is a well-ordered sequence of transactions. This includes transactions that failed. The important factors are recorded - who signed it, what the message contained, and the transaction's position in the canonical transaction order.

Since failure deducts a gas cost from the sender, the fact of the fail is important to record. It is part of the canonical story that explains the world state. It's not unlike a bank statement with the bad news. There must be an explanation for the calculation of the balance going forward.

Hope it helps.

  • So, from "it is possible to avoid failure by only signing transactions that should clear. It is also possible to front-run pending transactions perchance to create the conditions that will help a pending transaction succeed even if it was set to fail given conditions at the time it was signed" – mazakpe Aug 12 at 3:11
  • What are the conditions that would make me avoid the transaction failing? Are there any resources you could point me to? – mazakpe Aug 12 at 3:12
  • Generally, send enough gas. Have enough money. Observe the contract's rules. If the contract communicates with other contracts, the same for that. It is possible to send more funds than you have and then receive funds sufficient to cover before the first transaction is mined. It might help to think of pending transactions as checks in the mail. Whether they work or not depends on conditions when they are processed, not when they were signed. – Rob Hitchens - B9lab Aug 12 at 13:56
  • Thanks for upvoting all the answers and comments that are useful. It's important to the success of this site. – Rob Hitchens - B9lab Aug 12 at 16:59
0

failed tx's get into the block because they consumed your gas anyway, the gas is translated to ETH with the term multiplication gasUsed * gasPrice = ETH

  • Yes, but if the failed shouldnt they be discarded? – mazakpe Aug 10 at 19:47
  • depends on why it failed.... if the operation was valid but for example you gave max gas limit = 20000 but when the EVM finished it saw that you need 40000 to complete, it will evaporate your gas and mark it failed – Nick Andriopoulos Aug 10 at 19:49
  • So, why doesn't the EVM, automatically estimate how much gas required for a particular tx and save the developer from the evaporating your gas and marking the tx as failed? – mazakpe Aug 10 at 19:53
  • because you used the processing power of the swarm, you can calculate it before you transmit the transaction to the swarm your self if you like.... – Nick Andriopoulos Aug 10 at 19:55

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.