Site icon Stratus Crypto

How to Calculate Bitcoin Transaction Fees

Calculating the size of a Bitcoin transaction can vary depending on the type of wallet you’re using, the current miner’s fee rate and the quantity of inputs and/or outputs processed.  

An Unspent Transaction Output (UTXO) is Bitcoin’s answer to solve the problem of double-spending.  

A UTXO is the output from a previous transaction, like when someone sent you Bitcoin as a payment or your DCA bot made a purchase.  

The sender ‘spent’ their UTXO input to satisfy the transaction and resulted in your wallet receiving an ‘unspent’ amount in BTC minus the miner’s network fee (txn fee).    

Space in the block is limited, so the premium is on the size of the data.  

When you create a Bitcoin transaction, you can choose a higher fee to incentivize the miners to prioritize your transaction in the next block or default to a lower fee which will increase the time to process. This is a Pay-for-Priority fee model where the upper and lower bound rates are influenced by the amount of network activity (supply/demand). 

The mempool, displays the current transactions fees relative to the spot price of Bitcoin like this:

In December 2023, there was significant Mempool congestion due to the start of a Bull Market 4 months out from the halving.  Peak fees of 200+ sat/vByte have begun to normalize around 50-60 sat/vByte.  Fast forward to 2024, congestion eased and fees dropped significantly to ~12-15 sats/vByte.

From May 2020, a block reward of 6.25 BTC is paid to the miner (or mining pool) who completes a new block.  

Every 210,000 blocks mined (approximately 4 years), the coinbase block reward is halved.  This is Bitcoin’s hard coded method to prevent inflation due to new Bitcoin being mined over time.  

As the block reward for miner’s reduces over time, it’s likely that the price of Bitcoin will increase along with the fees paid out in Satoshis/vByte.  As fees go up, understanding that the size, not the value, of a Bitcoin transaction has the greatest impact on network fees.

Bitcoin Transactions are Measured by Data Size & Weight: 

Calculating the size and cost of a Bitcoin transaction depends on a number of factors:

Pro Tip: Confirm that your (sending) wallet supports the wallet format of the recipient to avoid errors or losing your Bitcoin.  Trust Wallet, for example, does not support Legacy and P2SH address formats. 

The most cost-effective way to minimize your fees is to use a SingleSig Native SegWit (bech32/P2WPKH) address.  When creating a new wallet address, make sure to select Native SegWit (segregated witness) address which starts with bc1q to save the most on fees.

SegWit was introduced to reduce the Bitcoin transaction data’s size optimizing for speed, scalability and decreased fees compared to the other address formats.  

Before SegWit, blocks used to be limited to 1,000,000 bytes (1MB).  After SegWit’s release block limits were expanded by a factor of 4 because of the way signature data is removed out of the ‘input’ section and into the ‘witness’ section.  

Think of 1,000,000 bytes 1(MB) = 1,000,000 letters or numbers that could fit in a block.  

Segwit makes it so that 4,000,000 letters or numbers referred to as Weight Units (WU)  can fit into each block.  

Weight Units are their own unit of measurement.  Similar to bytes, but with SegWit you can fit 4,000,000WU  letters and numbers into the same 1,000,000B (byte) space.

The ‘virtual’ size of the transaction (vBytes) is ¼ the ‘raw’ data size.  You can fit up to 4x more data into the same amount of block space.  BlockSize > BlockWeight

Ugh!!!  I’m writing this for normies, not Bitcoin Core Devs.  This is part of going down the rabbit hole.  Let’s keep moving.  

Bitcoin Transaction Components and Size Estimate

Quick math to calculate transaction size with multiple inputs and outputs: 

Transaction Size (in bytes) = (Number of Inputs * 148) + (Number of Outputs * 34) + 10.5

Every transaction starts with input UTXO(s) which will be spent.  Input UTXOs range from 57.5 vB – 148 vB plus an additional 10-10.5 vB of overhead. 

Pro Tip: If a transaction has multiple outputs, each additional output adds another 31-43 vB to the total size.  If a transaction has multiple inputs, each additional input adds 148 vB of data to the total size/weight of the transaction. 

The average data size of a single-sig 1 input : 1 output UTXO transaction is ~200 vB (99-202.5).  (Multi-sig wallet transaction UTXOs average more like 400 vBytes.) 

Many transactions have a ‘change’ UTXO back to the sender adding another ~45 vB (output + overhead) bringing the average to ~245 vB for a single-sig 1 input : 2 output transaction. 

Transaction Overhead, Input, & Output detailed data size:

The size of the transaction can vary due to wallet type, additional signatures and extra hashes. 

Here’s a tool to experiment with to calculate the size of a transaction based on the inputs and outputs.  Compare it against a different calculator here.

How do multiple inputs affect transaction size and cost:

Multiple input UTXOs may be required if you don’t have a single UTXO equal to or greater than the amount of Bitcoin you are sending.   The specific input UTXOs may be selected manually using coin control or automatically depending on your wallet features and preferences.  

Example of a BTC transaction with multiple inputs and outputs:

Using the formula we can compute the transaction size in virtual bytes:

Transaction Size (in bytes) = (2 * 148) + (2 * 34) + 10.5

Transaction Size (in bytes) = 296 + 68 + 10

Transaction Size (in bytes) = 374 vBytes (virtual bytes)

The transaction size in this example is 374 bytes.  This is proven using quick math looking at the mempool where the average size of a block is 1.5 MB / 4,000 transactions per block = 375 (bytes).

Example of Transaction Size with 30 UTXO Inputs

Let’s assume you are using Stratus DCA bot with a recurring buy of $10 each day.

Maybe you’re anticipating a government 6102 attack and vigilantly move your crypto off-exchange to cold storage every day even though you know that frequent transfers off-exchange will increase future transaction fees. 

At the end of the first month, you’d have 30 UTXOs in your cold wallet and need to consolidate UTXOs.  

Transaction type: P2WPKH (bech32 – bc1q)

Average Cost: $40,000 BTC:USD

UTXO Consolidation Transaction Size:  2,113 vBytes

Total Network Fee: $16.90   ($0.008 x 2,113 vBytes)

It’s worth noting that if you waited to transfer everything at the end of the month you would have 1 UTXO because exchanges DO NOT create a UTXO for every transaction.  The exchange would simply send the amount you requested minus their fees + Bitcoin Network fees.

PartCountSize (vBytes)Total vBytes
Overhead110.510.5
Inputs30682040
Outputs23162

Calculating the Transaction Size using Different Address Formats

The data size of the locking script* varies based on the wallet address format used.

The different types of locking scripts include: Pubkey, PubkeyHash, Multisig, Script Hash.  

Your fee rate is determined by the type of script you use to lock the Output. Pay-to-Pubkey-Hash (P2PKH), Pay-to-Script-Hash (P2SH), Pay-to-Witness-Script-Hash (P2WSH), Pay-to-Taproot (P2TR). 

Example comparing fees with P2PKH:

Native SegWit (bech32) is the most cost effective way to transact with Bitcoin because there is less data and miner fees are calculated based on the size of your transaction which is expressed in vBytes.   

How do I reduce my Bitcoin transaction fees?

There are several ways to reduce your transaction fees including:

  1. Use a lower fee rate when for the transaction.
    1. If the biotin to adjust fee rate is available, you can set the lower fee rate (1 sat/vByte lowest).  The transaction is at risk of being stuck, but most nodes will drop the transaction after 3 days if it hasn’t been confirmed.  
    2. If a transaction is stuck after 3 days and/or you need to push it through sooner, you can amend your transaction using (fee bumping) Replace By Fee (RBF) to replace the original transaction with another similar transaction that pays a higher fee.  It’s as simple as opening the wallet where you initiated the transaction and clicking the ‘Increase Fee’ button to change your fee to be more competitive. Child-Pays-For-Parent (CPFP) is an alternative solution to get a txn unstuck.
  2. Time your transfers for days with low activity (lower fee rate)
    1. Typically network fees are lower on the weekend when network activity is down.  You can you can use a pseudonymous, non-KYC tool to receive email alerts: https://txfees.watch
  3. Consolidate UTXOs
    1. Consolidating UTXOs combines the two previous strategies with active management of the unspent outputs in your wallet.  

The cost of transferring 1 BTC using a single sig P2PKH transaction (~245 vBytes of data) during different fee environments & UTXO quantities is modeled below…

~245 vBytes1 sat/vByte10 sat/vByte100 sat/vByte
5 UTXOs1,225 sats          
(0.000012 BTC = $0.50)
12,250 sats  
(0.00012 BTC = $5.25)
122,500 sats   
(0.0012 BTC = $52)
25 UTXOs6,125 sats          
(0.000061 BTC = $2.60)
61,250 sats  
(0.00061 BTC = $26)
612,500 sats        
(0.01 BTC = $260)
100 UTXOs24,500 sats          
(0.00025 BTC = $10.50)
245,000 sats  
(0.0025 BTC = $105)
2,450,000 sats     
(0.02 BTC = $1,050)

The cost of transferring 1 BTC using a single sig P2WPKH (bech32) transaction (~140.5 vBytes of data) during different fee environments & UTXO quantities is modeled below…

~140.5 vBytes1 sat/vByte10 sat/vByte100 sat/vByte
5 UTXOs702.5 sats          
(0.000007 BTC = $0.29)
7,025 sats  
(0.00007 BTC = $2.94)
70,250 sats    
(0.0007 BTC = $29.4)
25 UTXOs3512.5 sats       
(0.000035 BTC = $1.47)
35,125 sats  
(0.00035 BTC = $14.70)
351,250 sats        
(0.0035 BTC = $147)
100 UTXOs14,050 sats          
(0.00014 BTC = $5.88)
140,050 sats  
(0.0014 BTC = $58.80)
1,40,500 sats     
(0.01 BTC = $420)

By now you should have a solid understanding that your transaction cost is impacted by three primary factors: Bitcoin wallet address format, quantity of UTXOs, and the network fee rates.

Different fee environments come and go based on supply and demand for block space.  It’s difficult to predict what the network fee will be in the future.  

It’s your responsibility to proactively manage your UTXOs and use address formats that consume the least amount of data to create efficient Bitcoin Transactions.

Note: Stratus does NOT provide investment, legal or tax advice.  All information in this article is for educational purposes and should not be interpreted as investment, legal or tax advice.  The opinions expressed are those of the author for informational purposes and neither Stratus nor the author are liable for any errors, inaccuracies or omissions.  Digital assets, such as cryptocurrencies or decentralized finance, present unique risks for investors.  For investment, legal, tax, or other financial guidance you should consult your own advisor. 

Exit mobile version