Author

Topic: How to calculate the tx fee? (Read 1153 times)

newbie
Activity: 12
Merit: 1
December 01, 2017, 03:27:21 AM
#8
The subject of bitcoin fees is an important part of understanding how the blockchain works.
Here is are some relevant articles with deeper looks on the subject of bitcoin fees:

https://99bitcoins.com/bitcoin-fees-explained/

https://icowatchlist.com/blog/calculate-bitcoin-transaction-fees/

http://coinour.com/index.php/how-to-predict-the-transaction-fees/

Hope it helps Smiley
legendary
Activity: 3808
Merit: 7912
June 19, 2017, 09:49:05 PM
#7
My last input was 0,5 BTC.

But if I send 0,5 BTC it will use an other input for the fee which makes it much more expensive.


If I send 0,498 BTC it will only cost 0,0007 BTC fee. (Because it can use 1 input I guess)

If I send 0,5 BTC I have to pay around 0,0015 BTC. (Because it uses more than 1 input)



Never knew this principle before.



 I think you can still do this.  Make sure to attach a fee of at least 0.0001 btc/kb and then use ViaBTC.com accelerator. 
Wait until the unconfirmed tx pool is less populated.
legendary
Activity: 3472
Merit: 4801
June 19, 2017, 03:24:51 PM
#6
Correct, the fee you pay when you send bitcoins is all about how you receive the bitcoins

. . .To be a "proper" transaction fee, the fee must be computed in terms of bitcoins (or satoshis) PER BYTE. The number of BTC being transferred does not matter.

The necessary fees change constantly depending on how many transactions are waiting for confirmation.  If there are no transactions waiting for confirmation at all, it is entirely possible to get a transaction confirmed with 0 fees (or extremely low fees).  If there are lots of transactions waiting, then you'll need to pay more per byte than most of the waiting transaction so that miners will want to confirm your transaction instead of the others that are waiting.

If you know what the size of your transaction (in bytes) will be then the following website can be used to estimate what your fee should be:
https://bitcoinfees.21.co/

That site keeps an eye on the transactions that are waiting and the transactions that are getting confirmed, and it estimates what fee you'd need to pay per byte to get confirmed quickly.

The size (in bytes) of a transaction depends on the number of inputs and the number of outputs.

The transaction will typically have 10 bytes required for the framework of the transaction.

If you are only sending to a single address with your transaction then the transaction will only have 1 or 2 outputs.  Each output is 34 bytes.

Your wallet will choose from the transactions that were paid to you in the past to supply value to the transaction.  Each of the previous payments you received that it chooses adds another input to the transaction.  Each input will probably be 148 bytes.



So, for example, if you previously received 8 payments to your wallet:
  • 0.1 BTC
  • 0.5 BTC
  • 0.04 BTC
  • 0.25 BTC
  • 0.0001 BTC
  • 0.34 BTC
  • 0.0032 BTC
  • 0.9 BTC
  • 0.00005 BTC

And you want to send 1.75 BTC to someone.  Your wallet might choose the following 4 inputs (I've color coded them in red above so you can see them):
  • 0.9 BTC
  • 0.5 BTC
  • 0.34 BTC
  • 0.04 BTC

That provides a total of:
0.9 + 0.5 + 0.34 + 0.04 = 1.78 BTC of value to the transaction.

Now your wallet creates 1 output of 1.75 BTC to send the bitcoins where you wanted them to go.

This leaves:
1.78 BTC - 1.75 BTC = 0.03 BTC of value remaining in the transaction.

The total size of the transaction so far is:
(4 inputs X 148 bytes each) + (1 output X 34 bytes each) + 10 bytes = 636 bytes.

If the transaction doesn't do anything with that extra 0.03 BTC, then it becomes a transaction fee.
That would be an excessive fee:
0.03 BTC / 636 bytes = 0.00004717 BTC (or 4717 satoshis) per byte.

Lets imagine for a moment that 180 satoshis (0.00000180 BTC) per byte is a reasonable fee...

So the transaction needs ANOTHER output so it can send the excess "change" BTC back into the wallet (sort of like getting $15 in change when you pay with a $20 bill for something that costs $5).

This extra output will add another 34 bytes to the transaction.  The transaction is now 670 bytes.

So, since we are imagining that we want to pay 180 satoshis per byte, and the final transaction size is 670 bytes (4 inputs and 2 outputs) we need a fee of:
180 satoshis per byte X 670 bytes = 120600 satoshis (or 0.001206 BTC).



Now lets imagine that you are using a faucet to collect BTC (that's a HORRIBLE idea). Let's say the faucet pays you 0.00001 BTC every 60 seconds, and you find a way to work the faucet 24 hours a day without missing a payment.

After 1 month, you will have collected 43,200 payments of 0.00001 BTC each.  You will have a total of 0.432 BTC.

Now you want to send 0.01 BTC to someone.

Your wallet needs to choose 1000 of those 0.00001 BTC payments to add up to 0.01 BTC. That's 1000 inputs!.

1000 inputs X 148 bytes per input = 148000 bytes.

Even if you only have 1 (34 bytes) output (plus the 10 bytes of framework), that's still 148044 bytes.

If the fee is going to be 180 satoshis per byte, then your fee to send the transaction will be:
180 satoshis per byte * 148044 bytes = 26647920 satoshis (or 0.26647920 BTC).



As you can see, the fee doesn't depend on the amount of BTC being sent.

In the first example, you can send 1.75 BTC with a fee of only 0.001206 BTC

In the second example, sending 0.01 BTC requires a fee of 0.2664792 BTC . . .

So, the lesson is not to receive small payments if you can avoid it, and use wallet software that does a good job of optimizing which received payments to spend so that it can minimize the inputs and outputs in the long run.
hero member
Activity: 1308
Merit: 508
June 19, 2017, 02:13:32 PM
#5
My last input was 0,5 BTC.

But if I send 0,5 BTC it will use an other input for the fee which makes it much more expensive.


If I send 0,498 BTC it will only cost 0,0007 BTC fee. (Because it can use 1 input I guess)

If I send 0,5 BTC I have to pay around 0,0015 BTC. (Because it uses more than 1 input)



Never knew this principle before.

vh
hero member
Activity: 699
Merit: 666
June 19, 2017, 02:07:59 PM
#4
Yea, one or two inputs should be under 250 bytes.   
0.00086971  / 250 = 348sat/B
legendary
Activity: 3808
Merit: 7912
June 19, 2017, 01:59:46 PM
#3
As long as there is only one input and one or two outputs, you can send 0,5
vh
hero member
Activity: 699
Merit: 666
June 19, 2017, 01:56:45 PM
#2
Hey guys,

let's say I have 0.50086971 BTC on my wallet - how much of that am I able to send in 1 transaction and how much is the fee?

I guess it isn't enough to send 0,5 BTC?

You can send all of it minus fees in one transaction.

Some wallets will suggest fees (based on inputs + outputs), just make sure it falls in one of the layers in this graph that is affected by the falling edge:

https://jochen-hoenicke.de/queue/#2h
hero member
Activity: 1308
Merit: 508
June 19, 2017, 01:27:21 PM
#1
Hey guys,

let's say I have 0.50086971 BTC on my wallet - how much of that am I able to send in 1 transaction and how much is the fee?

I guess it isn't enough to send 0,5 BTC?
Jump to: