# Ethereum TX Fees/Gas Gambling Calculation

I'm wondering if there's a better way of handling the transaction fee limit. As I understand it at the moment, it's basically a gamble. You wager an amount. If it is too low, you lose it all when it gets rejected and returned. Set it too high and you waste money on faster processing you didn't want.

How can I set a sensible amount? Must I rely on online calculators to make the guess for me?

I sent 0.01 Eth with a 0.0003 fee, and it's been stuck for days, I'm guessing insufficient fee and thus rejected.

https://www.ethgasstation.info/ is a good resource for setting the right gas price.

If you set the gas price too low, your transaction just doesn't get picked up, and it costs you nothing.

If you set the gas price to high, then yes, you spent more on the transaction than you needed to.

I don't know what a "0.0003" fee means. A normal transaction of ether (to a normal account, not a contract) costs 21,000 gas. You can then pick a gas price, e.g. 23 gwei. 21,000 gas * 23 gwei / gas = 483,000 gwei = 0.000483 ether ~= \$0.63 USD. So I'm guessing you set a lower gas price than that, and the computed fee in ether was a little low?

You can just submit a new transaction with the same nonce and a higher gas price. How you do this depends on what tool you're using. (MetaMask has a button to retry, MEW has a tool specifically for this, and tools like `geth` let you set your own nonce if you want.)

• What I read strongly suggests that if a transaction runs out of gas, then you lose the gas that was already spent. And thus lose money on a failed transaction. But you're suggesting there is no way to lose money unless the transaction completes successfully? My 0.0003 fee was the total of gas price times gwei, as seen in the Ethereum Wallet. Commented Jan 16, 2018 at 10:46
• It's correct that if you run out of gas, then you pay for the gas that was already used. So if the gas limit is set too low, you can lose ether by paying for the gas that was used. But there's no reason to have too low of a gas limit, since it can be accurately determined ahead of time, and there's little downside to setting it a bit high in the rare case that it can't be determined (since you only pay for what's used). What you typically change is the gas price (how much you pay per gas), and there, if you set too low of a value, the consequence is that your transaction doesn't get mined. Commented Jan 16, 2018 at 10:52
• My guess is that 0.0003 was the gas limit times the gas price (usually expressed in gwei). Gas is what you're buying, and the gas price is what you pay per gas. ("Gas price times gwei" makes no sense... it's like saying "Unit price times dollars.") Commented Jan 16, 2018 at 10:57
• That's what I meant to say :). I was tired. Gas limit times gas price. Surprised it was too low though, given it's about \$0.5, for sending about \$11. Thanks for clearing up the gas limit usage for me. Commented Jan 16, 2018 at 23:03
• The transaction fee doesn't relate to how much ether you're transferring. ethgasstation.info says \$0.87 is currently a reasonable transaction fee for a simple ether transfer. Commented Jan 16, 2018 at 23:05

Your description implies a misunderstanding of how it works.

# General Explanation:

The gas-fee is a function of two variables:

1. The number of gas units required for the transaction to execute
2. The price (in wei-ether) of each gas unit

The first variable derives solely from the number of machine operations (opcodes) executed during the transaction, and the types of those operations (different types consume different amounts of gas).

The second variable is configured by you before sending the transaction, and it is therefore the only "gambling factor" in the process, which impacts how fast your transaction will be executed.

It is true that before sending the transaction you also configure the gas-limit, but that's just an extra precautionary measure provided in order for you to protect yourself from executing some inefficient contract function which consumes a lot more gas units than what you're willing to spend.

This parameter is NOT the first variable mentioned above.

It just has to be equal to or higher than that variable, otherwise the transaction will not be executed.

Furthermore, you will not "lose it all when it gets rejected":

• When you configure a gas-limit lower than the number of gas units required for the transaction to execute, the transaction will be rejected and your account will not be charged anything
• When you configure a gas-limit equal to or higher than than the number of gas units required for executing the transaction, the transaction will be executed and your account will be charged by your gas-price times the number of gas units which were actually used, even if your gas-limit was higher than that number