How is the network fee generated?
Most cryptocurrencies have a fixed block size, meaning that only a finite number of transactions can be included in a block at a time.
For example, the current block size in the Bitcoin network is 1 MB, and a new block appears every 10 minutes. Only 2000-3000 transactions can fit into one block. Formally, this is the current throughput limitation.
The mechanism of fees is necessary to pay for the services of the distributed network, where the network service is data storage. Users pay for each byte of data added to the shared database. And since the throughput of this database is limited, users compete for priority in recording.
Another important function of fees is to protect against transaction spam. The presence of mandatory fees means that it would be costly for an attacker to flood the network with fake transactions over a long period, which could paralyze the blockchain if they have such intentions.
How does the process of cryptocurrency transfer work from a technical point of view?
After you sign and send a transaction to the network, it enters the transaction queue, known as the mempool.
Since a block can only contain a limited number of entries, there are times when the network is congested and there are many pending transactions in the queue. To avoid confusion, a compromise solution was introduced, which is the mechanism of fees. In other words, for a miner, the priority is given to transactions that offer the highest reward for them - the difference between the incoming and outgoing amounts in the transaction.
It is important to note that such fees are always charged only from the sender, not the recipient.
How to calculate the fee?
Each of these operations requires payment, but not all transactions are equal. The more information needs to be transmitted, the more space it will occupy in the block. Therefore, the cost is calculated not based on the transfer amount, but on the volume of data. Miners strive to get as much fee as possible, so sometimes it is more profitable for them to take two small transactions with an average fee rather than one large transaction with a recommended fee.
The cost of a Bitcoin transaction is not dependent on the transaction amount but on the number of addresses involved.
There is no need to understand how much space each transaction occupies; fees are specified as a price per byte (unit of information). In other words, the fee will automatically adjust depending on the amount of data being transferred. However, if you want to estimate the final fee amount, you can approximate it in advance.
For example, for Bitcoin:
- Each address from which funds are received adds approximately 148 bytes.
- Each address to which funds are sent adds approximately 34 bytes.
- Plus, there is a basic transaction size of 10 bytes, regardless of the number of addresses.
For Ethereum, things are a bit more complicated. The payment unit in the Ethereum network is "gas."
Each operation requires a certain amount of gas, regardless of the exact number of bytes. Here, users pay for the number of operations that miners/validators need to perform to verify the transaction.
For example, transferring ETH from one wallet to another requires 21,000 gas. However, creating or executing smart contracts may require a different amount of "gas" because a contract can perform different operations during its execution.
The full list of costs for each operation can be found in the technical documentation: Yellow Paper (Page 27).
Again, there is no need to delve into the nuances. The user sets a certain gas price that they are willing to pay,and the system automatically calculates everything based on the required number of operations. There is a concept called "gas limit," which is the maximum amount of gas you are willing to spend. Any unused gas will be fully refunded to the sender, so often this amount is specified with a margin. Typically, wallets calculate this amount automatically.
Important: Do not confuse "gas limit" and "gas price"!
In the Ethereum blockchain, the maximum block size is measured not in bytes like in Bitcoin but in the amount of "gas." This helps minimize manipulation of the fee size by miners (or validators since September 2022).
How and why to specify a commission?
The size of the commission determines the speed at which a transaction enters a block. Setting a too low commission can lead to significant delays in transaction confirmation. Setting an excessively high commission leads to unjustified expenses.
During times when the network is congested and too many people are sending funds simultaneously, you will have to increase the transaction fee. Other users follow this rule as well, resulting in an avalanche-like surge in commission fees.
The record holder in the Ethereum network is a transaction from 2016 that paid a commission of 761 ETH (although Ethereum was worth significantly less at that time, so the final cost amounted to around $6,000).
Modern cryptocurrency wallets are designed so that users don't have to worry about what is happening behind the scenes. The user enters the recipient wallet address, the transfer amount, and the commission size, which has already been calculated for them in advance, and confirms the transfer with a password.
However, if you want to have the ability to use more fine-tuned commission settings, there are special services for commission estimation:
• for Bitcoin - bitcoinfees.earn.com (the most suitable commission at the current moment is in the "green zone," a level at it or higher than that guarantees the fastest transaction processing).
• for Ethereum - etherscan.io (the site provides three recommended fees: minimum, standard, and high-priority).
It is considered that when a transaction enters a block, it receives the first confirmation, as a miner records it in the blockchain. Each subsequent block added to the chain after the block with our transaction adds one new confirmation.
Due to the peculiarities of blockchain operation, which we will discuss in future publications, many services require 3-6 confirmations for Bitcoin and 20-30 confirmations for Ethereum before considering the transaction successfully completed.
But what should you do if you specified a low commission?
Sometimes, out of ignorance, newcomers may intentionally specify very low fees, resulting in operations waiting a long time in the queue. However, there are other cases when spikes in activity can occur in the blockchains due to certain events, often causing a transaction that was sent with an optimal fee to be pushed back to the end of the queue because a large number of new participants arrive and assign higher fees than the previous ones.
At the turn of 2017 and 2018, when the price of Bitcoin reached historical highs at that time, fees reached $40 per transaction due to an incredible number of pending transfers. Some transactions remained in the queue for weeks until the excitement gradually subsided.
In most cases, it is sufficient to simply wait for the excitement to die down — a few hours, sometimes days. But there are cases when a transaction needs to be carried out urgently. Is there anything that can be done?
For such emergency cases, there are two mechanisms: "replace-by-fee" and "child-pays-for-parent." Unfortunately, very few wallets implement the functionality for the first mechanism, which allows directly changing the commission size in a transaction already sent to the queue.
However, almost all wallets can utilize the second function. Its essence is to send a transaction from a wallet that is expected to receive the change from a stuck transaction with an intentionally inflated commission, so that it becomes profitable for miners to process both transactions at once.