Pages:
Author

Topic: How do we calculate the correct transaction fee to send? (Read 525 times)

legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
There are various wallets/exchanges that provides you the estimated or even the exact transaction fee, one example for the wallet is Mycelium. The transaction fee is based and calculated through the amount you have inputted, the priority of the transaction that you selected, and the current state of the mempool, particularly, the traffic.
Users have previously mentioned that it's entirely not based from the amount.

If your comment is based from self-experience, it's most likely that you have multiple inputs with small amounts that it would take 2 or more inputs to fulfill the high amount you've inputted.

e.g.: Let's say you've received 0.0001, 0.00011 and 0.00012 BTC before that aren't consolidated into 1 UTXO.
If you need to send 0.00009 BTC; it will only have to use 1input, thus smaller transaction size and lower fee.
If you need to send 0.0003 BTC; it will have to use all three inputs, thus higher transaction size and higher fee.
sr. member
Activity: 1764
Merit: 260
isn't there a simple site where you can input few data and it gives you an estimated transfer fee?  I want to know how much it costs to transfer 10 Bitcoin from 1 wallet to another wallet.


There are various wallets/exchanges that provides you the estimated or even the exact transaction fee, one example for the wallet is Mycelium. The transaction fee is based and calculated through the amount you have inputted, the priority of the transaction that you selected, and the current state of the mempool, particularly, the traffic.
legendary
Activity: 2268
Merit: 18771
isn't there a simple site where you can input few data and it gives you an estimated transfer fee?  I want to know how much it costs to transfer 10 Bitcoin from 1 wallet to another wallet.
Sites will generally give a suggested fee rate, rather than an absolute fee. The fee rate should be in the format of sats/vbyte. This is how much satoshi you will pay for each virtual byte of space your transaction takes up. The number of virtual bytes a transaction takes up is dependent on the number of inputs, the number of outputs, the exact type of those inputs and outputs (legacy, segwit, etc), and a few other factors.

For example, if your transaction was 2000 vbytes and you paid 1 sat/vbyte, you would pay 2000 sats. Your transaction would be right at the bottom of the current mempool, since miners care more about the fee rate than the absolute fee.
If your transaction was 250 vbytes and you paid 8 sats/vbyte, you would also pay 2000 sats, but this time your transaction would be much nearer the top of the current mempool.

A transaction moving 10 bitcoin could involve 1 input and 1 output and therefore be as low as 110 vbytes in size, or it could involve 100 inputs (or more) and be thousands of bytes in size. It all depends on across how many inputs that 10 bitcoin is spread.
legendary
Activity: 2380
Merit: 5213
isn't there a simple site where you can input few data and it gives you an estimated transfer fee?  I want to know how much it costs to transfer 10 Bitcoin from 1 wallet to another wallet.
Note that transaction fee doesn't depend on the amount you send. So, it doesn't matter whether you are sending 1000 BTC or 1000 satoshi.
When you make a transaction, you should set the fee rate according to network state and how fast you want your transaction to be confirmed. The total fee depends on number of inputs and outputs and address(es) type as well. You can use bitcoindata.science (a tool created by the forum user, bitmover) to calculate the total fee based on number of inputs and outputs, your address type and the fee rate.
newbie
Activity: 19
Merit: 4
isn't there a simple site where you can input few data and it gives you an estimated transfer fee?  I want to know how much it costs to transfer 10 Bitcoin from 1 wallet to another wallet.

legendary
Activity: 1652
Merit: 1483
in practice, miners would ignore such transactions unless they paid ridiculously high fees. so it doesn't happen.
such transaction won't even be relayed as it would be non-standard so it doesn't exist in 99.9% of the node's mempool. the only way to see something like this is for a miner to both create this transaction and mine it in which case there is no need to pay any fees.

point taken, it wouldn't normally be relayed by nodes. however, that just means the spender needs to send the transaction to miners out-of-band. Tongue
legendary
Activity: 3472
Merit: 10611
in practice, miners would ignore such transactions unless they paid ridiculously high fees. so it doesn't happen.

such transaction won't even be relayed as it would be non-standard so it doesn't exist in 99.9% of the node's mempool. the only way to see something like this is for a miner to both create this transaction and mine it in which case there is no need to pay any fees.
legendary
Activity: 1652
Merit: 1483
because only limited number of transactions will get place in the block (~4MB).
A block (at present) can never contain 4 MB worth of transactions.

The limit on a block at present is 4,000,000 weight units. See my reply on the previous page for a brief explanation of what weight units are. Legacy transactions are only non-witness data, so take up 4 weight units per byte, and a block could fit a maximum of 1 MB. Witness data takes up 1 weight unit per byte, so if a block contained nothing but witness data, it would be 4 MB.

There are no transactions which are just witness data, though. SegWit transactions contain both non-witness (at 4:1) and witness (at 1:1) data. A block filled with regular SegWit transactions and no legacy transactions has an upper limit of somewhere around 2.5 MB. The biggest block we've ever seen so far was block number 566575, at 2.377 MB.

there are edge cases where we could theoretically get very close to 4MB. https://bitcoin.stackexchange.com/a/54949

Quote
The best possible size to weight ratio I can think of is a transaction which also spends a P2WSH output that has a ridiculous redeemscript. And then there's also the coinbase transaction and block header. The witness would be 4000000 - 240 * 3 - 240 = 3999040. So there is 3999040 bytes in the witness. The total block size is then 3999040 + 240 = 3999280 bytes.

in practice, miners would ignore such transactions unless they paid ridiculously high fees. so it doesn't happen.
legendary
Activity: 2268
Merit: 18771
because only limited number of transactions will get place in the block (~4MB).
A block (at present) can never contain 4 MB worth of transactions.

The limit on a block at present is 4,000,000 weight units. See my reply on the previous page for a brief explanation of what weight units are. Legacy transactions are only non-witness data, so take up 4 weight units per byte, and a block could fit a maximum of 1 MB. Witness data takes up 1 weight unit per byte, so if a block contained nothing but witness data, it would be 4 MB.

There are no transactions which are just witness data, though. SegWit transactions contain both non-witness (at 4:1) and witness (at 1:1) data. A block filled with regular SegWit transactions and no legacy transactions has an upper limit of somewhere around 2.5 MB. The biggest block we've ever seen so far was block number 566575, at 2.377 MB.
sr. member
Activity: 1274
Merit: 265
I use electrum wallet and usually I drag the cursor to left to set lowest fee, then click preview and you can see how many bitcoins are being deducted as fee. I don't know about other wallets.
hero member
Activity: 1358
Merit: 851
Perfect! It means most of bitcoin transactions have been made in America and European continents and locals there tend to use higher fees (likely), whilst the Asia and Australia continents tend to make less numbers of transactions as well as they likely are ready to move their coins with lower fees.
It's not because some people pays higher fees or some pays lower. If someone needs faster confirmation, they are likley to pay higher fee. Since we have limited space on block (4MB per block now), if there are a lot of transaction pending, you are likely to pay the maximum fee for faster confirmation if you are in hurry because only limited number of transactions will get place in the block (~4MB). That's how fee increase and decrease. No one is likely to pay higher fee unless they need to.
legendary
Activity: 2044
Merit: 1018
Not your keys, not your coins!
Generally when you see a surge in the mempool size, and therefore the average fee, it is usually around 13:00 - 23:00 UTC, which corresponds to day time in most of Europe, and initially the east coast and then all of the Americas. Conversely, the mempool is usually fairly empty, with fees around 1-2 sat/byte, around 01:00 - 06:00 UTC, when the aforementioned continents are generally sleeping and Australia and eastern Asia are awake.
Perfect! It means most of bitcoin transactions have been made in America and European continents and locals there tend to use higher fees (likely), whilst the Asia and Australia continents tend to make less numbers of transactions as well as they likely are ready to move their coins with lower fees.
legendary
Activity: 2268
Merit: 18771
At those times difference is for sure bigger.
A bigger contrast is seen at times of the day. Go to https://jochen-hoenicke.de/queue/#1,6m and zoom in (by selecting an area on the graph) on a random week or so in the last few months. Generally when you see a surge in the mempool size, and therefore the average fee, it is usually around 13:00 - 23:00 UTC, which corresponds to day time in most of Europe, and initially the east coast and then all of the Americas. Conversely, the mempool is usually fairly empty, with fees around 1-2 sat/byte, around 01:00 - 06:00 UTC, when the aforementioned continents are generally sleeping and Australia and eastern Asia are awake.

You can use this to your advantage to plan non-urgent transactions, such as consolidating all your small inputs.
legendary
Activity: 2744
Merit: 1288
Also, suppose the transaction is not urgent (say changing BTC between own wallets or sending to a relative), can it be sent with very low fee? What's the worse that can happen - will the transcation get cancelled/not go through on the blockchain?

Not directly related, but you mention not urgent transaction. I noticed that usually mempool gets fuller towards end of the week and empty over weekends. So cheapest day to send a transaction is Sunday. Or the fastest day to send cheap transaction.

You made me curious about transaction fee in different days of week.
I calculated the average transaction fee for different days of the week in the past three months. (Raw data from https://bitinfocharts.com/)

Monday: 0.70 $
Tuesday: 0.70 $
Wednesday: 0.71 $
Thursday: 0.71 $
Friday: 0.74 $
Saturday: 0.63 $
Sunday: 0.57 $

You were right. I hadn't ever noticed this.

LOL well I never went to check exact numbers but saw it just by looking at mempool graphs. And we of course usually look at mempool when is more full then usually Smiley   At those times difference is for sure bigger.
legendary
Activity: 2268
Merit: 18771
By the way, could you help me with the conversion of fees from satoshi/ byte to satoshi / vbyte, please.
The difference between: https://coinb.in/#fees and https://btc.com/stats/unconfirmed-tx, then how to make conversion?
So, the simple answer here is that coinb.in/#fees is stating the fee in sats/vbyte, although they call it sats/byte. We can tell this because the transaction sizes they show are different for legacy and SegWit transactions.

The longer answer is more complicated, and there is no straightforward way to "convert" between the two, since it depends entirely on the particular transaction you are looking at.

Plain bytes are not used to measure the size of transactions anymore, since the SegWit soft fork. Instead we use weight units. You can read more about these here: https://en.bitcoin.it/wiki/Weight_units. Essentially, insteading of blocks being able to hold 1 million bytes, they now hold 4 million weight units. For legacy transactions, each byte takes up 4 weight units, so the effective size of these transactions doesn't change. For SegWit transactions, however, the witness data only takes up 1 weight unit per byte, so the effective size is smaller. To prevent having to multiply and divide by 4 all the time, lots of people instead use virtual bytes or vbytes, which again, are equal to 4 weight units. So a block can contain 1 million vbytes.

This means that for legacy transactions, 1 byte of transaction data takes up 1 vbyte on the block, but for SegWit transactions, 1 byte of witness data will only take up 0.25 vbytes of block space (the non witness data is unchanged, and still takes up 1 vbyte per byte). This makes SegWit transactions take up less block space, and therefore, cost less in fees.

Now for some examples. Take a look at this legacy transaction: https://blockchair.com/bitcoin/transaction/b74c4d36e9835923556b34f53fead7c9d51c03435e80805a2c8b904852a8a35f

You can see its size is 224, and its weight is 896, which is exactly 4 times its size. This is because it is a legacy transaction. Its fee per vbyte and fee per byte are the same.

Now look at this SegWit transaction: https://blockchair.com/bitcoin/transaction/dcddd311deb7c4a4a2b63b10bc762badc7a0fcefd7afc336838cc2f57e326360

It has a size of 374, but its weight is only 1,169, which is about 3.1 times its size. Its fee per vbyte is higher than its fee per byte, because some of the bytes (the witness data) are "discounted" as explained above.
legendary
Activity: 2044
Merit: 1018
Not your keys, not your coins!
This a poor graph to use to visualize the mempool in the context of working out a fee. A better choice is the third graph on Johoe's site here (https://jochen-hoenicke.de/queue/#1,8h) entitled "Mempool Size in MB".

The reason for this is because the graph you linked to shows the number of unconfirmed transactions, whereas the graph I've linked to shows the size in MB of these unconfirmed transactions. Why is this important? I'll use two examples to illustrate my point. Lets say first of all that the mempool contains 10,000 transactions, but each transaction is less than 250 vbytes in size. This means the mempool is actually relatively empty at only 2.5 MB, and could completely empty in only 3 blocks. Conversely, lets now say the mempool contains only 1,000 transactions, but they are all huge consolidation transaction from various exchanges, and each one is 30,000 vbytes in size. Now the mempool is the fullest it has been in months at over 30 MB.

So using the graph you linked, if we see 1,000 or 10,000 transaction, we don't actually know how full the mempool is because we don't know the size of those transactions, which is what actually matters. Blocks are limited by size, not by number of transactions. A block could contain anywhere from 0 to over 4000 transactions.
Thank you. I did not realize that importance. The number of transactions and sum size of transactions in membpool are very different, and the difference play important role to consolidate coins, especially if people consolidate their coins with low fees.

By the way, could you help me with the conversion of fees from satoshi/ byte to satoshi / vbyte, please.
The difference between: https://coinb.in/#fees and https://btc.com/stats/unconfirmed-tx, then how to make conversion?
legendary
Activity: 2380
Merit: 5213
Also, suppose the transaction is not urgent (say changing BTC between own wallets or sending to a relative), can it be sent with very low fee? What's the worse that can happen - will the transcation get cancelled/not go through on the blockchain?

Not directly related, but you mention not urgent transaction. I noticed that usually mempool gets fuller towards end of the week and empty over weekends. So cheapest day to send a transaction is Sunday. Or the fastest day to send cheap transaction.

You made me curious about transaction fee in different days of week.
I calculated the average transaction fee for different days of the week in the past three months. (Raw data from https://bitinfocharts.com/)

Monday: 0.70 $
Tuesday: 0.70 $
Wednesday: 0.71 $
Thursday: 0.71 $
Friday: 0.74 $
Saturday: 0.63 $
Sunday: 0.57 $

You were right. I hadn't ever noticed this.
legendary
Activity: 2744
Merit: 1288
Also, suppose the transaction is not urgent (say changing BTC between own wallets or sending to a relative), can it be sent with very low fee? What's the worse that can happen - will the transcation get cancelled/not go through on the blockchain?

Not directly related, but you mention not urgent transaction. I noticed that usually mempool gets fuller towards end of the week and empty over weekends. So cheapest day to send a transaction is Sunday. Or the fastest day to send cheap transaction.
legendary
Activity: 2268
Merit: 18771
In order to make sure that you choose the right time to move your coins, take a look at mempool: https://www.blockchain.com/charts/mempool-count?timespan=60days.
This a poor graph to use to visualize the mempool in the context of working out a fee. A better choice is the third graph on Johoe's site here (https://jochen-hoenicke.de/queue/#1,8h) entitled "Mempool Size in MB".

The reason for this is because the graph you linked to shows the number of unconfirmed transactions, whereas the graph I've linked to shows the size in MB of these unconfirmed transactions. Why is this important? I'll use two examples to illustrate my point. Lets say first of all that the mempool contains 10,000 transactions, but each transaction is less than 250 vbytes in size. This means the mempool is actually relatively empty at only 2.5 MB, and could completely empty in only 3 blocks. Conversely, lets now say the mempool contains only 1,000 transactions, but they are all huge consolidation transaction from various exchanges, and each one is 30,000 vbytes in size. Now the mempool is the fullest it has been in months at over 30 MB.

So using the graph you linked, if we see 1,000 or 10,000 transaction, we don't actually know how full the mempool is because we don't know the size of those transactions, which is what actually matters. Blocks are limited by size, not by number of transactions. A block could contain anywhere from 0 to over 4000 transactions.
newbie
Activity: 18
Merit: 0
The size of the fee depends on many factors, including the conditions of the wallet that you use. Everywhere conditions are different. Therefore, first of all, study the conditions of your wallet or better ask your wallet support to write everything in detail. Sometimes it’s a lot easier than figuring it out yourself!
Pages:
Jump to: