Gas
Gas corresponds to the actual operation steps of the Ethereum Virtual Machine (EVM) in a transaction. Simpler transactions, such as pure
For ether transfer transactions, the fewer operations steps are required, the less gas is required. Conversely, if you want to calculate some complex operations, the consumption of Gas
The amount will be large. Therefore, the more computations the EVM needs to perform in the transaction you submit, the higher the gas consumption required.
Gas Price
Gas Price is how much Eth you are willing to pay for a unit of Gas, generally using Gwei as the unit. So the higher the Gas Price, the
It means that for each operation step in the transaction, more Eth will be paid.
You may be unfamiliar with the unit Gwei. Gwei is actually 10 ^ -9 Eth, which means 1 Gwei = 0.000000001 Eth.
So, when you set Gas price = 20 Gwei , it means that you are willing to pay 0.00000002 Eth for a single step operation.
Having said that, if you are smart, you will realize that the calculation formula of Ethereum's fee is very simple:
Transaction Fee (Tx Fee) = Actual Steps (Actual Gas Used) * Step Price (Gas Price)
For example, your transaction requires Ethereum to perform 50 steps to complete the operation. Assuming that the Gas Price you set is 2 Gwei, then the handling fee for the entire transaction is
That's 50 * 2 = 100 Gwei.
Gas Limit
Gas Limit is the upper limit of Gas available in a transaction, that is, how many steps will be performed in your transaction at most. Due to the different complexity of transactions, the exact gas consumption will not be known until the transaction is completed, so before you submit the transaction, you need to set a gas consumption limit for the transaction.
If the transaction you submitted has not been completed and the gas consumption has exceeded the Gas Limit you set, then the transaction will be cancelled, and
The fees already consumed are also deducted - because the miners who have paid the labor are rewarded. If the transaction has been completed and the gas consumed does not reach the Gas Limit, then only the transaction service fee will be charged based on the actual gas consumed. In other words, the highest possible service fee for a transaction is Gas Limit * Gas Price.