How to Calculate the Bitcoin Transaction Fee?

How to Calculate the Bitcoin Transaction Fee?
Photo : Pexels

How to calculate the Bitcoin transaction fee? The more users who use Bitcoin to transfer money, the busier the miners will be. If the transaction fee is set too low, the transaction will be ignored by the miners. Bitcoin is a decentralized system, and the specific amount of fees is not regulated by an authoritative institution, but is formed by free competition in the market. So, how to calculate the Bitcoin transaction fee?

2021 Bitcoin transaction fee breakdown

Generally, an ordinary Bitcoin transaction is composed of one input and two outputs (transaction output and change output), about 200 bytes, if the default charge is 0.0001 Bitcoin per 1000 bytes, then a Bitcoin transfer procedure The fee is about 0.001-0.002 bitcoins. But when a single input is not enough to pay for the output, the above-mentioned multiple transaction input constitutes an unspent output problem, and its data volume will become larger at this time. The more complex the output of unspent transactions, the more bytes that need to be processed, and the higher the handling fee.

When you use the Bitcoin client to send bitcoins, the whole process is roughly divided into the following steps:

Step 1: Choose the appropriate unspent output

As mentioned earlier, the transaction will eventually leave multiple unspent outputs, and these unspent outputs will not be merged! For example, if you receive two payments, 2BTC and 3BTC, these two unspent outputs will Stored separately in the wallet, and will not be merged into 5BTC.

When you want to pay someone else in Bitcoin, the Bitcoin client will select the appropriate unspent output and send it out as the input for the next transaction.

Step 2: Discourage piecemeal payments

Bitcoin's current algorithm discourages fragmented payments, because a large number of fragmented payments will increase transaction data and cause slow transactions in the entire system. If the "output" of the transaction is less than 0.01 BTC, then a handling fee of 0.0001 BTC will be charged. The wallet has an established rule when preparing your payment amount, which is to avoid changes in the amount less than 0.01BTC when preparing the payment amount in many inputs (for example, if you want to pay 5.005BTC, the wallet should choose 3+2.005 as much as possible Or 1+1+3.005. instead of 5+0.005).

Step 3: The higher the amount, the older the currency, the higher the priority

Every transaction will have a priority. Whether a transaction needs to pay a commission depends on the size of the following priority value (just a simple model, the real situation is more complicated):

If the value of X is less than 0.576, the transaction will be charged, and if X is greater than 0.576, priority can be obtained to avoid charging.

Have you found out that there is a situation that will definitely be charged, that is, the money paid is originally small, and it is composed of multiple scattered money, and the time for you to get the scattered money is very close, then this The transaction will not escape being charged.

On the contrary, if the input amount of the transaction is large and the time is long, it can avoid being charged.

Step 4: "Weighing" charges

Bitcoin transactions appear as a string of digital data. The transaction containing more data will take up more disk space and require more network bandwidth to transmit. Therefore, the more complex the input and output items of a transaction, the larger the amount of data, and the more handling fees that need to be paid.

For example, once someone wants to give a prize to a user, the prize is BTC worth 66 yuan, using an online wallet to send bitcoin, but every time a prize is issued, a handling fee of about 50 yuan will be deducted, and then it will be sent to the blockchain. A look in the browser shows that the online wallet uses fragmented scattered money. A small transaction actually has 6 inputs, which causes the transaction data volume to increase and a lot of transaction fees are deducted.

If you do not get the priority mentioned in the third point, then you must charge a transaction fee! You must "weigh" the size of your transaction.

The formula for weighing is:

Size=148*input quantity+34*output quantity+10

The fee is charged per kilobyte (less than 1k is calculated as 1k), and the fee per kilobyte is 0.0001 BTC. The output quantity of a typical transaction is two: one is for the payee, and the other is for system change. According to the above weighing formula, paying 0.0001BTC, the maximum number of inputs can only be 6 transactions. If the number of inputs is 7 transactions, the transaction fee will be doubled to 0.0002BTC.

© 2024 iTech Post All rights reserved. Do not reproduce without permission.
* This is a contributed article and this content does not necessarily represent the views of itechpost.com

Tags

Company from iTechPost

More from iTechPost