Ethereum's operating environment is also known as Ethereum virtual machine (EVM).
Each node participating in the network will run EVM as part of the block verification protocol. All nodes in each network will perform the same calculation and store the same value.
This is what we often call blockchain distributed storage.
Contract execution will be repeated many times in all nodes, and anyone can publish and execute contracts.
This leads to a result: the cost of contract execution is very expensive.
In order to prevent deliberate attack or abuse of Ethereum network, Ethereum protocol stipulates that each operation step of transaction or contract call needs to be charged.
The cost is measured in gas, commonly known as fuel.
one
Basic concepts of Ethereum transaction
The term "transaction" is generally understood as "barter" or "money barter" in the field of traditional economics.
In Ethereum, the most intuitive understanding is: send from one account to another account on the blockchain, including messages and signed packets.
It includes the following contents:
Sender's signature
Received address
Amount of digital currency transferred
For these contents, we can get the corresponding information by viewing the transfer transaction. The viewing method will be described later.
Eth has many units of measurement: Finney, Szabo, Gwei, mwei, Kwei and Wei, among which Gwei is commonly used.
Wei is the smallest eth unit.
The detailed conversion table is shown in the figure below.
Exchange rate: 1ether = 10 ^ 18wei
For specific exchange rate query, you can view the following websites:
https://jin10086.github.io/etherconverter/
Before calculating transaction costs, we need to understand the meaning of two terms:
Gaslimit value
This represents the most allowed calculation steps for the execution of this transaction. Generally, the default value can be used without adjustment.
Gasprice value
It represents the gas fee that the transaction sender is willing to pay, which can be set by himself. The more you pay, the faster you pack.
two
How are transaction costs calculated
There is a formula for calculating transaction costs: gas = gas limit * gas price
Take the following figure as an example. If you want normal and low speed, you can set the gas fee of 1.5-1.6. If you want high speed to be packaged within 2 minutes, you need to give nearly twice the price - 3.
Before each transaction, you can check the following website to confirm the gasplice to be set:
https://ethgasstation.info/
Any transaction needs to consume gas, but if the transaction fails, less fees will be deducted.
For example, the following ratio transaction is set to 153gwei and gas limit 40000
If the transaction is successful, the maximum deduction fee is 153 * 40000 = 0.062ether.
If the transaction fails, the actual deduction is 0.003697398 ether.
three
How to query your transaction
No matter in any wallet, each transaction will produce a txhash,
You can https://etherscan.io , check your transaction status,
Take metamask as an example. The following figure shows the transaction records
Click a transaction record at will to view the status of the transaction.
There are three statuses: pending, success and failed. Pending means being confirmed, success has been successful and failed means failure,
A certain fuel fee will be deducted for any state transition, which can be viewed in the actually paid fuel fee.
The above figure is a detailed analysis of the picture of each transaction data. With reference to this description, you can understand the specific information of any transfer