Bitcoin Forum
April 19, 2024, 02:39:37 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to calculate transaction fees ?  (Read 443 times)
ronmike (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 0


View Profile
January 25, 2018, 11:14:22 AM
 #1

I am using bitcore server https://github.com/bitpay/bitcore and below is the code for making a transaction

Code:

var tx = bitcore.Transaction();
tx.from(utxos);
tx.to(address2,50000);
tx.change(address);
tx.sign(privateKey);
tx.serialize();

How much transaction fees are taken for executing the above transaction.? and I want to check before the transaction goes for the execution.
1713494377
Hero Member
*
Offline Offline

Posts: 1713494377

View Profile Personal Message (Offline)

Ignore
1713494377
Reply with quote  #2

1713494377
Report to moderator
1713494377
Hero Member
*
Offline Offline

Posts: 1713494377

View Profile Personal Message (Offline)

Ignore
1713494377
Reply with quote  #2

1713494377
Report to moderator
1713494377
Hero Member
*
Offline Offline

Posts: 1713494377

View Profile Personal Message (Offline)

Ignore
1713494377
Reply with quote  #2

1713494377
Report to moderator
The grue lurks in the darkest places of the earth. Its favorite diet is adventurers, but its insatiable appetite is tempered by its fear of light. No grue has ever been seen by the light of day, and few have survived its fearsome jaws to tell the tale.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713494377
Hero Member
*
Offline Offline

Posts: 1713494377

View Profile Personal Message (Offline)

Ignore
1713494377
Reply with quote  #2

1713494377
Report to moderator
1713494377
Hero Member
*
Offline Offline

Posts: 1713494377

View Profile Personal Message (Offline)

Ignore
1713494377
Reply with quote  #2

1713494377
Report to moderator
1713494377
Hero Member
*
Offline Offline

Posts: 1713494377

View Profile Personal Message (Offline)

Ignore
1713494377
Reply with quote  #2

1713494377
Report to moderator
AGD
Legendary
*
Offline Offline

Activity: 2069
Merit: 1164


Keeper of the Private Key


View Profile
January 25, 2018, 12:24:54 PM
 #2

You can read everything about Bitcoin fees here: https://en.bitcoin.it/wiki/Transaction_fees

Bitcoin is not a bubble, it's the pin!
+++ GPG Public key FFBD756C24B54962E6A772EA1C680D74DB714D40 +++ http://pgp.mit.edu/pks/lookup?op=get&search=0x1C680D74DB714D40
Marrying_Couch
Newbie
*
Offline Offline

Activity: 182
Merit: 0


View Profile
January 25, 2018, 03:44:20 PM
 #3

You can read everything about Bitcoin fees here: https://en.bitcoin.it/wiki/Transaction_fees

all is available here, we just understand what we do not understand, so no one in the deal.
akiash
Newbie
*
Offline Offline

Activity: 152
Merit: 0


View Profile
January 25, 2018, 05:00:31 PM
 #4

You can read everything about Bitcoin fees here: https://en.bitcoin.it/wiki/Transaction_fees

Hi AGD,
I would really appreciate if you could give me piece of advice on this. What is the best way to send cryptocurrency from one exchange to another. I can see that if I send BTC, is has higher fees.
Stedsm
Legendary
*
Offline Offline

Activity: 3052
Merit: 1273



View Profile
January 25, 2018, 06:16:58 PM
Merited by ABCbits (1)
 #5

You can read everything about Bitcoin fees here: https://en.bitcoin.it/wiki/Transaction_fees

Hi AGD,
I would really appreciate if you could give me piece of advice on this. What is the best way to send cryptocurrency from one exchange to another. I can see that if I send BTC, is has higher fees.

That's something already fixed that you're asking about. Exchanges charge a "fixed" fee for a transaction that they execute on their end and you are bound to pay those fees if you are withdrawing your coins from an exchange to exchange or even a wallet. You can only decide fee while you are sending "your" coins that you have in your wallet, and not an exchange. The "fixed" fee charged by them is what they take per transaction, not the fee they actually send while sending you your "withdrawn" amount. One more thing, each exchange has different "fixed" fee levels, like Polo charges 0.0005 BTC per withdrawal, Bittrex takes 0.001 BTC and so on.

██████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
██████████████████████
.SHUFFLE.COM..███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
█████████████████████
████████████████████
██████████████████████
████████████████████
██████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
██████████████████████
██████████████████████
██████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
.
...Next Generation Crypto Casino...
Salmen
Legendary
*
Offline Offline

Activity: 1059
Merit: 1020


View Profile WWW
January 25, 2018, 07:32:55 PM
Merited by ABCbits (1), AGD (1)
 #6

If no fee is given, a transaction with an optimal fee according to the size and network traffic will be sent. Otherwise, if a custom-fee is given which can be done like the example on the below, you overwrite the fee amount.

Code:
var transaction = new Transaction()
    .from(utxos)          // Feed information about what unspent outputs one can use
    .to(address, amount)  // Add an output with the given amount of satoshis
    .change(address)      // Sets up a change address where the rest of the funds will go
    .sign(privkeySet)     // Signs all the inputs it can
var transaction = new Transaction().fee(5430); // Minimum non-dust amount
var transaction = new Transaction().fee(1e8);  // Generous fee of 1 BTC

To record this transaction on the blockchain, you have to serialize the variable transaction, and thereby, push to the network through https://blockchain.info/pushtx.

Source: https://bitcore.io/api/lib/transaction

Young Developer amidst Europe. Specialized in Web Programming and Creating Telegram Bots. Looking for a developer? Feel free to drop a mail to me.
Running JaguarBitcoin - Your Place For Scripts
akiash
Newbie
*
Offline Offline

Activity: 152
Merit: 0


View Profile
January 25, 2018, 09:14:40 PM
 #7

You can read everything about Bitcoin fees here: https://en.bitcoin.it/wiki/Transaction_fees

Hi AGD,
I would really appreciate if you could give me piece of advice on this. What is the best way to send cryptocurrency from one exchange to another. I can see that if I send BTC, is has higher fees.

That's something already fixed that you're asking about. Exchanges charge a "fixed" fee for a transaction that they execute on their end and you are bound to pay those fees if you are withdrawing your coins from an exchange to exchange or even a wallet. You can only decide fee while you are sending "your" coins that you have in your wallet, and not an exchange. The "fixed" fee charged by them is what they take per transaction, not the fee they actually send while sending you your "withdrawn" amount. One more thing, each exchange has different "fixed" fee levels, like Polo charges 0.0005 BTC per withdrawal, Bittrex takes 0.001 BTC and so on.
Thanks. That helps. Recently I transferred some BTC from coinbase to binance and they charged me around 18 USD for that transaction. If I'm going to transfer some money from binance to other exchange, what is the best format of cryptocurrency I should send in order to minimize the fees.
AGD
Legendary
*
Offline Offline

Activity: 2069
Merit: 1164


Keeper of the Private Key


View Profile
January 26, 2018, 06:03:27 AM
 #8

You can read everything about Bitcoin fees here: https://en.bitcoin.it/wiki/Transaction_fees

Hi AGD,
I would really appreciate if you could give me piece of advice on this. What is the best way to send cryptocurrency from one exchange to another. I can see that if I send BTC, is has higher fees.

That's something already fixed that you're asking about. Exchanges charge a "fixed" fee for a transaction that they execute on their end and you are bound to pay those fees if you are withdrawing your coins from an exchange to exchange or even a wallet. You can only decide fee while you are sending "your" coins that you have in your wallet, and not an exchange. The "fixed" fee charged by them is what they take per transaction, not the fee they actually send while sending you your "withdrawn" amount. One more thing, each exchange has different "fixed" fee levels, like Polo charges 0.0005 BTC per withdrawal, Bittrex takes 0.001 BTC and so on.
Thanks. That helps. Recently I transferred some BTC from coinbase to binance and they charged me around 18 USD for that transaction. If I'm going to transfer some money from binance to other exchange, what is the best format of cryptocurrency I should send in order to minimize the fees.

Most of the Altcoins have a lower fee, but you will lose some % when you want to exchange back in BTC.

Bitcoin is not a bubble, it's the pin!
+++ GPG Public key FFBD756C24B54962E6A772EA1C680D74DB714D40 +++ http://pgp.mit.edu/pks/lookup?op=get&search=0x1C680D74DB714D40
cry4crypto
Member
**
Offline Offline

Activity: 140
Merit: 35


View Profile
January 26, 2018, 02:03:05 PM
Merited by Welsh (3)
 #9

There are also multiple online fee calculators out there if you don't feel like calculating yourself. To name a few:

https://estimatefee.com/
http://bitfees.info/
https://www.cheaperfee.com/
https://coinb.in/#fees

I am in no way affiliated with any of these sites by the way, but hope you find either of them useful.
buwaytress
Legendary
*
Offline Offline

Activity: 2786
Merit: 3436


Join the world-leading crypto sportsbook NOW!


View Profile
January 26, 2018, 03:07:47 PM
Last edit: January 26, 2018, 03:25:30 PM by buwaytress
Merited by LFC_Bitcoin (2), achow101 (1), Welsh (1), ABCbits (1)
 #10

To add in on the other answers here, since OP still wants to know how to calculate tx fees... the most important piece of information you need is the size of your transactions. Doesn't seem to be in those lines of code, but they do have pieces of info that you can use to estimate size (not very accurately but close enough):

- number of inputs you're using, a
- number of outputs you'll create, b

Then: a*180 + b*34 + 10 +/- 1

which is why a 1 input, 1 output tx, the most common one, results in a typical tx size of 225 bytes. If you're using SegWit, your txs are going to be smaller (edit: added "in weight"), so this is a safe formula to use.

Easiest for me is to use the rough formula automatically done in site suggested above (estimate fee) so that's your best point to start finding out tx size, and then you crosscheck with another estimator with an easier to see structure like bitcoinfees.earn.com to see how much you need to pay per byte, for the estimated confirmation time you're comfortable with.

██
██
██
██
██
██
██
██
██
██
██
██
██
... LIVECASINO.io    Play Live Games with up to 20% cashback!...██
██
██
██
██
██
██
██
██
██
██
██
██
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6505


Just writing some code


View Profile WWW
January 26, 2018, 04:03:10 PM
 #11

Then: a*180 + b*34 + 10 +/- 1
Unless you are using uncompressed public keys (and very few wallets do this anymore), the input multiplier will be 148 instead of 180.

Carlton Banks
Legendary
*
Offline Offline

Activity: 3430
Merit: 3071



View Profile
January 26, 2018, 06:07:59 PM
Last edit: January 26, 2018, 07:07:59 PM by Carlton Banks
Merited by Welsh (1), hatshepsut93 (1), ABCbits (1), buwaytress (1), Jet Cash (1), veleten (1), Samarkand (1)
 #12

and then you crosscheck with another estimator with an easier to see structure like bitcoinfees.earn.com to see how much you need to pay per byte, for the estimated confirmation time you're comfortable with.

Strongly recommend against using bitcoinfees.earn.com (which is the same as bitcoinfees.21.co), especially for those that aren't familiar with Bitcoin fee estimating, bitcoinfees.21.co/bitcoinfees.earn.com suggests incorrect estimates for confirmation times.

The text delivering the "answer" is highly misleading: "The fastest and cheapest transaction fee is currently: 220 satoshis/byte" (which at this point in time is around 10 times more than an equally fast fee rate).

The site's conf-time estimate seems to erroneously deem the "cheapest and fastest" fee to be that which is paid very near to the highest within the top 1MB of it's mempool, when in fact every transaction within the top 1MB will be equally fast (yet not equally cheap).

It's likely no coincidence that 200 sat/byte transactions are heavily represented in the typical Bitcoin mempool. Very little mempool space is occupied inbetween this so called "cheapest and fastest" threshold and the lowest fee within the top 1 MB of the mempool (which is 10 times lower than 200 sat/byte right now).

Their method for calculating fees therefore always presents users with a false impression of confirmation times, and likely distorts the fee market against the user's interests. I am most embarrassed to have recommended this website in the past.

Vires in numeris
hatshepsut93
Legendary
*
Offline Offline

Activity: 2954
Merit: 2144



View Profile
January 26, 2018, 09:31:06 PM
Merited by achow101 (2), ABCbits (1), buwaytress (1)
 #13

and then you crosscheck with another estimator with an easier to see structure like bitcoinfees.earn.com to see how much you need to pay per byte, for the estimated confirmation time you're comfortable with.

Strongly recommend against using bitcoinfees.earn.com (which is the same as bitcoinfees.21.co), especially for those that aren't familiar with Bitcoin fee estimating, bitcoinfees.21.co/bitcoinfees.earn.com suggests incorrect estimates for confirmation times.


Probably the best way to check the current fees is to go to https://dedi.jochen-hoenicke.de/queue/#2h and look at the mempool size to see what fees are getting included in recent blocks by looking at spike drops. Also, this should be another incentive to run a full node, as SPV clients have to trust their servers to get fee estimations (correct me if I'm wrong).

.BEST.CHANGE..███████████████
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
██
███████████████
..BUY/ SELL CRYPTO..
buwaytress
Legendary
*
Offline Offline

Activity: 2786
Merit: 3436


Join the world-leading crypto sportsbook NOW!


View Profile
January 27, 2018, 10:00:49 AM
Merited by Carlton Banks (1), achow101 (1), ABCbits (1)
 #14

and then you crosscheck with another estimator with an easier to see structure like bitcoinfees.earn.com to see how much you need to pay per byte, for the estimated confirmation time you're comfortable with.

Strongly recommend against using bitcoinfees.earn.com (which is the same as bitcoinfees.21.co), especially for those that aren't familiar with Bitcoin fee estimating, bitcoinfees.21.co/bitcoinfees.earn.com suggests incorrect estimates for confirmation times.

The text delivering the "answer" is highly misleading: "The fastest and cheapest transaction fee is currently: 220 satoshis/byte" (which at this point in time is around 10 times more than an equally fast fee rate).

The site's conf-time estimate seems to erroneously deem the "cheapest and fastest" fee to be that which is paid very near to the highest within the top 1MB of it's mempool, when in fact every transaction within the top 1MB will be equally fast (yet not equally cheap).

It's likely no coincidence that 200 sat/byte transactions are heavily represented in the typical Bitcoin mempool. Very little mempool space is occupied inbetween this so called "cheapest and fastest" threshold and the lowest fee within the top 1 MB of the mempool (which is 10 times lower than 200 sat/byte right now).

Their method for calculating fees therefore always presents users with a false impression of confirmation times, and likely distorts the fee market against the user's interests. I am most embarrassed to have recommended this website in the past.


Thanks for pointing that out... I confess I haven't been looking at the explanation paragraphs below the main charts for months and you're right. The graphs themselves are still helpful, I've always used the estimation with confirmation times that more or less correspond. But the "cheapest and fastest" estimation is definitely far from accurate, at least it is right now.

I've been recommending this estimator for months now so am as guilty for possibly getting other users to pay more fees than needed. Complacency...

I do note that the graphs themselves are still a useful tool but now should find something more representative.

Then: a*180 + b*34 + 10 +/- 1
Unless you are using uncompressed public keys (and very few wallets do this anymore), the input multiplier will be 148 instead of 180.

I learn something new every day here, thanks for pointing that out!

██
██
██
██
██
██
██
██
██
██
██
██
██
... LIVECASINO.io    Play Live Games with up to 20% cashback!...██
██
██
██
██
██
██
██
██
██
██
██
██
Carlton Banks
Legendary
*
Offline Offline

Activity: 3430
Merit: 3071



View Profile
January 29, 2018, 12:38:14 PM
Last edit: February 05, 2018, 11:36:15 AM by Carlton Banks
 #15

I confess I haven't been looking at the explanation paragraphs below the main charts for months and you're right. The graphs themselves are still helpful, I've always used the estimation with confirmation times that more or less correspond. But the "cheapest and fastest" estimation is definitely far from accurate, at least it is right now.

I've been recommending this estimator for months now so am as guilty for possibly getting other users to pay more fees than needed. Complacency...

Yeah, like I said, I have recommended bitcoinfees.21.co in the past without fully understanding how inaccurate it's estimates can be. And like you said, the raw information on the site is perfectly usable, but those looking for a simple answer are likely to assume the estimation (or even the "fastest & cheapest") figures are good, which they're not.

Vires in numeris
Hans17
Full Member
***
Offline Offline

Activity: 390
Merit: 157


View Profile
February 05, 2018, 07:17:37 AM
 #16

You can read everything about Bitcoin fees here: https://en.bitcoin.it/wiki/Transaction_fees

Wow didn't know about this and thank you though it really help me and to be honest I am doing some basic search about this , and now I know , thank's a lot though and for my opinion how to calculate the fees I think by the demand of it however the bitcoin or the cryptocurrency's price.

[
 
                                . ██████████.
                              .████████████████.
                           .██████████████████████.
                        -█████████████████████████████
                     .██████████████████████████████████.
                  -█████████████████████████████████████████
               -███████████████████████████████████████████████
           .-█████████████████████████████████████████████████████.
        .████████████████████████████████████████████████████████████
       .██████████████████████████████████████████████████████████████.
       .██████████████████████████████████████████████████████████████.
       ..████████████████████████████████████████████████████████████..
       .   .██████████████████████████████████████████████████████.
       .      .████████████████████████████████████████████████.

       .       .██████████████████████████████████████████████
       .    ██████████████████████████████████████████████████████
       .█████████████████████████████████████████████████████████████.
        .███████████████████████████████████████████████████████████
           .█████████████████████████████████████████████████████
              .████████████████████████████████████████████████
                   ████████████████████████████████████████
                      ██████████████████████████████████
                          ██████████████████████████
                             ████████████████████
                               ████████████████
                                   █████████
CryptoTalk.org| 
MAKE POSTS AND EARN BTC!
🏆
Ulap16
Newbie
*
Offline Offline

Activity: 26
Merit: 0


View Profile
February 06, 2018, 04:24:47 AM
 #17

I didn't know anything about transaction fees and so much information is available here. I'll do my own research now and try to calculate the fees.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!