DEV Community

Cover image for Ethereum Transaction Gas Fee
HassanHabibTahir
HassanHabibTahir

Posted on

Ethereum Transaction Gas Fee

Gas

Gas is the fuel of the Ethereum blockchain network. Gas is always paid in ether, Gas is the transaction fee paid to miners for executing and adding your transaction into the Ethereum blockchain. For every transaction you have to specify the value of the gas price and the gas limit, you want to set. Based on these values, the network calculates how much of a fee you are willing to pay for the transaction.

Gas Limit

The gas limit is the maximum unit of gas your transaction may take, in order to be executed on the Ethereum blockchain.If your transaction takes less gas, then the extra gas that you have provided will be refunded back to your wallet. If your transaction consumes all the gas and requires more gas to be executed, your transaction will fail, and gas will be consumed as part of the transaction fees.

Gas price

_The gas price is the price per gas unit you are willing to pay for executing your transaction. The unit of gas price is always defined in gwei. According to your gas price, miners decide to process your transaction. If the transaction has a higher gas price, there is a chance that your transaction will be processed early. If your gas price is low, then your transaction might be processed after a delay or when the blockchain is free to process low-gas-price transactions.
_

Example

_ From | 0x2001152bd1cc1d37d7c0d25cd10315351b45b4a6
To | 0x0587db0883defe769b49b78c11bdcc2f1f38b484
gas limit| 424843
gas price| 0.0000000.1(10 gwei)
gas(used) = 21000;

TxFee (max) = gas limit * gas Price;
TxFee(paid) = gas(used)*GasPrice;
TxFee(Returned)= TxFee (max) -TxFee(paid);
TxFee (max) = 424843 * 0.00000001 =0.00424843;
TxFee = 21000*0.00000001=0.00021;
TxFee(Returned) = 0.00424843-0.00021=0.00403843 _

Top comments (1)

Collapse
 
subhanprime profile image
Subhan Ali

thanks for this explination