Cause and Effect of Failed Transaction

Alan Lai
amberdata
Published in
3 min readJun 1, 2018

Since July 30, 2015, Ethereum has slowly climbed the ranks in the cryptocurrency field with its innovative implementation of smart contracts. With the use of the Ethereum Virtual Machine, users are able to interact with set protocols that are programmed to do almost anything. To prevent users from exploiting and flooding the system, Ethereum introduced gas which requires users to pay a fee to interact with smart contract. If users do not provide enough gas, then the transaction can fail and the gas will not be refunded. With smart contracts slowly dominating the majority of all transactions that occur on the blockchain, the amount of failed transactions will only continue to grow.

The graph shows that the transaction between 5/21/18–5/28/18 are mainly between EOA* to EOA is at 59.53% and the transactions between EOA to Contract2 is at 40.47%. *EOA — External Owned Account (Users)

So what are the causes of failed transactions?

Before explaining the two ways a transaction can fail, let’s look at what gas price, gas limit, and transaction fee are:

  • Gas price represents the cost of a unit of gas in Ether.
  • Gas limit represents the maximum amount of unit of gas one is willing to purchase during a transaction.
  • Transaction fee represents the amount required for a transaction to be added onto the blockchain. The formula to calculate transaction fees in Ether can be found below:

TX Fee = Gas Price * Gas Limit

The first way a transaction can fail is when the user inserts a gas limit that is not sufficient enough to pay for the transaction fee. As a result, the status of the transaction will be considered as a “Transaction failed” and the Ether used during the process will not be refunded.

The second way a transaction can fail is when a contract rejects the user’s transaction. Many smart contracts have “special exceptions” and “require rules”, such as “OwnerOnly.” Even though the transaction will be reverted, the Ether used during the process will not be refunded.

In both cases, the Ether will not be refunded because even though the transaction failed, miners are mining for the transactions, putting them into blocks, and securing the blockchain. To reward them, they will still receive the transaction fee.

The Total

Using data collected from the past year between 05/26/2017 to 05/26/2018, it was determined that:

*Ether = $618.34
A sample of the data table used to calculate the total and average transaction fee.

Conclusion:

With Ethereum becoming more mainstream, smart contracts will be utilized more and more. It is clear that many smart contracts may have inefficient codes or poor user experiences which has lead to tens of thousands being wasted. Thus, it is important to calculate the amount of gas needed before a transaction and investigate the smart contracts of a transaction to determine its conditions. By using Amberdata, users can determine the transaction fees using the formula above. Not only that, but users can determine the most cost efficient time to interact with smart contracts using the gas price prediction data. Finally, users can inspect smart contracts to determine its security which will help reduce the amount of rejected transaction.

A sample of the gas prediction data.

--

--