Skip to main content
Uruguay Can

News from across crypto

How Much Gas Does a Failed Ethereum Transaction Cost?

A failed Ethereum transaction costs gas used × effective gas price, not the gas limit. Find both receipt values and calculate your fee in ETH.

Uruguay Can Editorial

How Much Gas Does a Failed Ethereum Transaction Cost?

A failed Ethereum transaction costs the ETH fee for the gas it used before reverting. Ethereum charges for computation even when execution fails, while the revert rolls back that transaction’s state changes.

Your fee depends on gas used and the effective gas price

The gas limit is the most gas the transaction is allowed to use; it is not the amount you automatically pay. The fee is based on gas used multiplied by the effective gas price, which is the price paid for each unit of gas.

A failed token swap on KyberSwap follows the same rule: the swap’s token and contract state changes do not persist, but the computation already performed still uses gas. For more on this question, read how KyberSwap revert fees work.

Say a reverted transaction uses 50,000 gas and has an effective gas price of 20 gwei. These are illustrative values. Since 1 gwei is 0.000000001 ETH, 20 gwei equals 0.000000020 ETH per gas. Multiply 50,000 by 0.000000020 ETH to get a fee of 0.001 ETH.

Use the transaction receipt to find your actual fee

An Ethereum transaction receipt reports gasUsed and effectiveGasPrice. You can find these values in the transaction details on a block explorer, including for a reverted KyberSwap swap.

  1. Open the transaction in an Ethereum block explorer and find its receipt details.
  2. Note the values for gasUsed and effectiveGasPrice.
  3. If the price is shown in gwei, divide it by 1,000,000,000 to convert it to ETH per gas. Multiply that result by gasUsed.

The result is the fee in ETH for that transaction. For example, if the receipt shows 50,000 gas used and an effective gas price of 20 gwei, the calculation is 50,000 × 0.000000020 ETH = 0.001 ETH. Use the receipt values for your transaction because gas used and effective gas price can vary.

  • A revert rolls back the transaction’s state changes, but the gas already used still costs ETH.
  • Calculate the fee with gas used × effective gas price, after converting gwei to ETH per gas.
  • The gas limit is not the amount charged; the receipt gives you the values to calculate the fee.