1

When claiming an NFT (smart contract interaction), the gas fees would have been $50-$80, so I went to Advanced options in MetaMask, and turned down my willingness to pay for gas to around 25,000 units for a much lower gas fee of $6.

The transaction failed however (I guess because $6 gas fee is too low?), and my ETH wallet balance is now lower, meaning that the gas fee was taken even though the transaction failed.

Why are gas fees taken for (both?) failed transactions/contract interactions?

2

Gas is burned for units of work, like gas in your car is burned by miles. Different fees for different operations. A transaction will burn a certain amount of gas.

GasPrice is like the price at the pump. What you are willing to pay for work. Miners will prioritize transactions with a higher bid for gasPrice.

If a transaction runs out of gas before finishing, the transaction fails and the gas is consumed from the effort.

If a transaction is disallowed, you pay for the gas to make that determination. This is because there is usually no way to know if the transaction will succeed or fail without running it.

Reducing the gas you send with the transaction probably leads to failure. Playing with the gasPrice adjusts the cost and the confirmation time.

Hope it helps.

2
  • if Metamask always says "minimum gas price is 21,000" and I set it to 25,000 which meets the requirement, why would the transaction (a contract interaction) fail?
    – user610620
    Mar 14 at 13:16
  • The failure is not necessarily related to gas. Lowering it adds another probable cause. Raising it does nothing because unused gas is returned. Probably what you are doing is not allowed. Possibly there is an error in the contract. Mar 14 at 19:44
2

Just to add to Rob's answer:

Why are gas fees taken for failed smart contract interactions?

Because there's no way to tell the difference between transactions that have failed due to user error, and those that have failed due to user malice.

If gas fees weren't charged for failing transactions, then the network would be open to attack. A malicious user could, for example, submit transactions with deliberately insufficient gas, or craft deliberately convoluted contract interactions that would ultimately fail right at the end of their execution. If such things had no attached fee, then an attacker would incur no cost for spamming the network with failing transactions.

By charging for all interactions, the network protects itself from such spam.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.