Sub topic 11
Bitcoin Fees: Fee Rate Times Transaction Size
Bitcoin transaction fees pay miners for including a transaction in a block. The fee does not depend directly on the amount of bitcoin sent. A transaction sending 0.001 BTC can cost more than one sending 1 BTC if it takes more block space.
This chapter assumes you understand Bitcoin transactions at a basic level, including inputs, outputs, and satoshis. It also assumes you know that 1 BTC equals 100,000,000 satoshis.
The fee formula
Bitcoin fees use this formula:
fee in satoshis = transaction virtual size in vbytes × fee rate in satoshis per vbyte
A fee rate is often written as sat/vB, meaning satoshis per virtual byte. The transaction's virtual size, or vsize, measures how much block capacity it consumes after applying SegWit's weight rules.
For example, a transaction with a size of 141 vB and a fee rate of 10 sat/vB costs:
141 × 10 = 1,410 satoshis
That is 0.00001410 BTC.
| Value | Meaning |
|---|---|
| 141 vB | Transaction virtual size |
| 10 sat/vB | Fee rate |
| 1,410 satoshis | Transaction fee |
What determines transaction size
A Bitcoin transaction contains inputs and outputs.
- An input identifies an earlier unspent transaction output, or UTXO, and proves that you can spend it.
- An output creates a new spendable amount for the recipient or for your own change.
- Each input and output adds data to the transaction.
- Signatures and scripts also add data.
More inputs usually make a transaction much larger than more outputs. Combining many small UTXOs can therefore create a high fee. A transaction with one input and two outputs is often much smaller than one with five inputs and two outputs.
SegWit transactions separate some signature data from the main transaction data. Bitcoin assigns that data a lower weight, so the effective vsize can be smaller than the raw byte count. Legacy and SegWit address types can therefore produce different sizes for similar payments.
Fee rates and confirmation priority
Block space is limited. When many users want transactions confirmed, miners generally prefer transactions offering higher fees per unit of space. Wallets estimate fee rates from current demand and target confirmation times.
A higher fee rate can improve confirmation priority, but it does not guarantee immediate confirmation. A low-fee transaction may remain in the mempool, the temporary pool of unconfirmed transactions, until demand falls.
The sender usually chooses the fee. The recipient receives the output amount specified by the transaction. If the input total exceeds the payment and fee, the transaction normally creates a change output returning the remainder to the sender.
def btc_fee_sats(vsize_vbytes, fee_rate_sat_per_vb):
if vsize_vbytes <= 0 or fee_rate_sat_per_vb < 0:
raise ValueError("invalid transaction size or fee rate")
return vsize_vbytes * fee_rate_sat_per_vb
vsize = 141
fee_rate = 10
fee_sats = btc_fee_sats(vsize, fee_rate)
fee_btc = fee_sats / 100_000_000
print(f"{fee_sats} satoshis")
print(f"{fee_btc:.8f} BTC")Estimating before sending
A wallet can estimate size from the number and types of inputs and outputs. The final size can differ if the wallet selects different UTXOs or adds a change output. Always inspect the final fee and fee rate before broadcasting when the wallet provides those details.
Exercise
A transaction is 250 vB and uses a fee rate of 24 sat/vB. What fee does it pay in satoshis and BTC?
Show answer
The fee is 250 × 24 = 6,000 satoshis, which is 0.00006000 BTC.