Horu@horuweb3

Why gas fees are charged even when Ethereum transactions fail
You approved a transaction in your wallet to swap coins, but a moment later, it showed as 'failed.' Yet, looking at your wallet, your ETH balance has slightly decreased. Why was a fee charged if the swap didn't even happen?
On Ethereum, even if a transaction fails during the execution process after being included in a block, you may still have to pay for the computational resources used. We will look at this based on the Ethereum mainnet.
What are you paying gas fees for?
To process a transaction on Ethereum, the network performs tasks such as verifying signatures and executing necessary programs. 'Gas' is the unit representing the amount of computational work, and the gas fee is the network cost for that work.
Even if the intended swap never occurs, the work done to execute it up to the point of failure may have already been carried out. Therefore, if a transaction is included in a block and executed, costs for the used gas can be incurred regardless of the success or failure.
On Ethereum, the base fee is burned, and a separate priority fee goes to the block proposer. This structure is different from your wallet app taking these fees.
What happens to the coins I intended to swap if it fails?
For example, if a 'revert' occurs while a smart contract is checking transaction conditions, the state changes intended for that execution are rolled back. You can think of it as a situation where your tokens for the swap remain untouched, while the gas fee for the execution is paid separately.
However, not all issues that appear similar in your wallet are in the same state. If a malicious transaction succeeds and sends assets, or if you have previously granted permissions to another contract, those need to be checked separately.
In what cases might a failure occur?
There are cases where the price moves after you request a swap, preventing you from meeting the minimum reception conditions. There are also cases where execution is halted because the calculation cannot be finished within the gas limit you set.
According to official Ethereum documentation, if gas runs out during execution, all the gas set for the transaction may be consumed. On the other hand, if a contract checks conditions and reverts, the remaining gas is not necessarily all consumed. A failure does not always mean you pay the same amount.
Distinguishing between 'Pending' and 'Failed'
Transactions not yet included in a block may be pending. It is also possible that your wallet rejected the request before submission, or the network did not accept the transaction. You cannot lump these situations together with failed transactions that were actually included in a block and executed.
In the process of canceling a pending transaction or replacing it with another, if the newly submitted transaction is included in a block, a fee for that transaction may be incurred. Please check your transaction history for specific statuses and actual costs.
Things to check before trying again
First, check the network and transaction status in your wallet's history, and look into the reason for the failure on a linked block explorer. Your next steps may depend on whether the swap conditions were not met or if there was an issue with the gas limit and balance.
It is better to look at the reason for the failure rather than simply increasing the limit or repeatedly pressing buttons. Resubmitted transactions may also cost you if they are executed.
