dgnx.finance

Transaction failed out of gas what it means and how to fix

Every Ethereum transaction needs gas. Gas is the fuel that pays miners to include your transaction in a block. When you send a transaction, you set a gas limit - the maximum amount of gas you are willing to pay for. If the actual execution needs more gas than your limit, the transaction fails. It never completes. But the miners still did the work of trying, so you still pay.

This is the most common cause of failed transactions for users new to smart contracts. It is not the same as running out of ETH. You can have plenty of ETH and still fail for lack of gas.

Simple transfers vs. smart contract calls

A basic ETH transfer to another wallet consumes exactly 21,000 gas. The gas limit is predictable. Most wallets set it automatically, and it almost never fails.

Smart contract interactions are different. Swapping tokens on Uniswap, minting an NFT, depositing into a lending pool - each of these contracts executes code, and the amount of gas needed depends on the contract's logic, network congestion, and your specific inputs. A swap that costs 120,000 gas today might cost 180,000 gas at peak congestion. You cannot know the exact amount in advance.

If you set the gas limit too low, the transaction hits the wall. It stops. You get a red failure on Etherscan, and you pay for every gas unit the miner actually consumed, even though nothing useful happened.

How to check a failed transaction on Etherscan

Open Etherscan and paste your transaction hash. The overview page shows two numbers under the Gas heading:

Gas Limit - what you set. Gas Used By Txn - what the miner actually used.

If Gas Used equals Gas Limit, your transaction failed because it hit the cap. The miner burned through every unit you authorized, then stopped. The status field will read "Fail" with an error reason (commonly "out of gas" or "intrinsic gas too low").

If Gas Used is lower than Gas Limit, the failure came from something else - a revert in the contract logic, a slippage check, or an expired deadline. That is a different problem. The stillborn transaction is marked as failed, and the gas used is still charged.

Fixing it: retry with a higher gas limit

The fix is straightforward: send the transaction again but increase the gas limit. A common rule of thumb for unknown transactions is to set the limit to 300,000. For complex swaps or multi-step operations like adding liquidity, raise it to 500,000 or 800,000. Many DApps display a recommended gas limit. Use it.

In MetaMask, click "Advanced" in the gas settings. You will see fields for Gas Limit and Max Priority Fee. Do not touch the Max Priority Fee unless you want to speed up confirmation. Focus on Gas Limit. If the DApp suggests 120,000, try 200,000. The difference in cost is tiny - perhaps a few cents if priority fees are low - and the safety margin is worth it.

Some wallets also have a "live gas estimation" feature. MetaMask polls the network to predict what the contract will need. It is not perfect, but it is usually conservative enough. If you are repeating a transaction that failed, the estimation often adjusts upward automatically.

Why you pay for failure and how to avoid it

Paying for a failed transaction feels wasteful. You authorized the miner to spend up to X, they spent nearly X, and you got nothing. This is by design. Miners cannot know the transaction will fail before they start executing it. They run the code, it hits the limit, and they must record the failure on-chain. Otherwise, nodes would hang forever on dead transactions.

You can avoid most gas failures with two habits:

  1. Use a wallet that estimates gas correctly. MetaMask, Rabby, and Frame all query the contract's own gas estimation method. That estimate is typically the true cost plus a small buffer. Do not override it unless you actually know the contract's gas usage.

  2. Increase the limit for unfamiliar contracts. If you just found a new DeFi protocol, set the limit to 400,000 as a start. If the transaction succeeds, note the gas used for next time. If it fails, raise the limit.

There is no way to cancel a failed transaction and get the gas back. The chain does not issue refunds for failed attempts. The only thing you can control is the next transaction.

A final note: gas prices and gas limits are separate concepts. Gas limit is about quantity; gas price is about how much you pay per unit. A high gas price makes miners prioritise your transaction, but a low gas limit makes it fail. Solve the limit first. Speed comes second.

Not financial advice. dgnx.finance publishes market data and general information about digital assets. Crypto assets are volatile and you can lose everything you put in. Nothing here is a recommendation to buy, sell or hold, and we make no price predictions.

Prices are sourced from third parties and may be delayed or wrong. Verify anything you intend to act on against a primary source.

Back to getting started