Failed Transactions on Ethereum
Why ETH Transactions Fail and What to do About it
When a transaction fails on the Ethereum network, you are still charged. Transactions fail when there isn’t enough gas to pay for a transaction, or when a smart contract rejects a transaction.
You are still charged for failed transactions because miners need to confirm transactions to the chain whether they succeed or fail. So, you are paying for that regardless of whether your transaction goes through.
TIP: The transaction fee you pay on the Ethereum network is called “gas” (gas is a small amount of ETH paid for Ethereum transactions measured in units of ETH called GWEI).
The Two Main reasons For Failed Transactions: Slippage and Not Adding Enough Gas
If an approval or simple transaction failed, it is probably a gas issue. If your transaction failed on UniSwap or another DEX during a trade, it’s probably a slippage issue.
If you are getting failed transactions, you either need to add more gas by customizing gas before you start the transaction (you can also “speed up” a transaction by paying more later, for example, click “speed up” in MetaMask) and/or, if you are trading on a DEX, you need to increase slippage (done in settings on DEXs like Uniswap, SuhiSwap, etc.).
I suggest a slippage of at least 3% (but as high as 15% for illiquid pairs) and ‘fast gas’ or custom gas if using MetaMask (or the equivalent if not; check current gas prices to see how much gas is needed right now).
Not paying enough gas: Transactions failing because you didn’t pay enough for the transaction is easy to avoid in most situations. You avoid this by making sure you pay high enough gas fees upfront. In MetaMask, for example, you typically just have to stick with “normal” or “fast,” and this is going to be enough to account for any changes in gas prices. However, you can also check current gas prices and put in a custom gas amount (this can be smart if gas prices are rapidly increasing). For a single transaction or a batch of simple transactions like when you open a Maker Vault, this is basically all you need to know. Rarely if ever, will you have a basic transaction fail (instead, the worst case is you’ll have a slow transaction here or there… which you can speed up by adding more gas). Solution: Try paying more gas upfront or adding more gas to the current transaction to speed it up.
Having a transaction rejected on a DEX: Failed transactions are more likely on “AMM” DEX exchanges like Uniswap or 1Inch. You are executing multiple transactions at once, and the contract rejects the transaction. Sometimes this is a gas issue, but usually, it is a slippage issue (there wasn’t enough liquidity to fill you at the quoted price, so the exchange rejected your transaction). Solution: Adjust slippage tolerance upwards (you may need to go into advanced settings depending on the platform; a suggest at least 3%).
Conclusion
In other words, if your transaction fails:
- You either have a gas problem.
- Or, you have a slippage problem.
If you are on Uniswap or another DEX, you probably need to adjust slippage tolerance and not gas. If you are doing a single transaction, you probably have to adjust gas.
If you can adjust both, and especially if prices and gas fees are going wild, you may consider adjusting both gas and slippage to avoid failed transactions.
Failed transactions are most likely to occur during periods of volatility, and each transaction that fails will cost (sometimes a lot).
So if one transaction fails, slow down, refresh prices, adjust slippage and/or gas, and try again.
For more, I suggest checking out Uniswap’s FAQ section.
TIP: This only applies when using web3 wallets, dexes, etc. Centralized exchanges like Coinbase don’t use gas.
TIP: Paying to speed up a transaction can result in the transaction being stuck in some rare cases. Unsticking it can be a pain. You might consider not doing this and focusing on paying more upfront if you can help it. However, generally, if your transaction is being slow, paying to speed it up is the best solution. I personally speed up transactions all the time and have rarely had an issue.
TIP: If the prices of the coins you are trading are moving really fast, you may have to do a transaction very quickly and adjust slippage tolerance way up (for a really illiquid and volatile coin, 15% isn’t unheard of). If gas prices are moving really fast, you may have to overshoot by a good bit. The charts in both cases will clue you in as to what you have to do.
TIP: With slippage, you won’t necessarily incur the full slippage tolerance amount. That is only the max slippage amount. With gas, you will pay what you offer to pay. So… don’t offer to pay more than you are willing to pay, check the current gas fees, and aim toward a reasonable high end, and you’ll almost always be fine.