Understanding how to measure the size of a Bitcoin transaction is crucial for optimizing fees and blockchain efficiency. This guide explores three key metrics: Bytes, Weight Units, and Virtual Bytes—each serving distinct purposes in the Bitcoin ecosystem.
1. Bytes (b): The Fundamental Unit
Bytes represent the raw size of a transaction on disk or across the network. Every 2 hexadecimal characters in a transaction equate to 1 byte.
Key Features:
- Measures actual data storage (e.g., blockchain files).
- Historically tied to Bitcoin's 1 MB block size limit (pre-SegWit).
- Calculated by counting hexadecimal pairs in transaction data.
Example Transaction: 01000000000101dd40a8d7f105055e781afa632207f5d3c4b4f4cad9f0fb320d0f0aa8e1ba904b0000000000ffffffff021027000000000000160014858e1f88ff6f383f45a75088e15a095f20fc663f841c0000000000001976a9142241a6c3d4cc3367efaa88b58d24748caef79a7288ac02483045022100d66341c3e6ce846b92bedcf9bc673ab8e47b770c616618eb91009e44816f4c2f0220622b5ebf6afabee3f4255bbcb84609e1185d4b6b1055602f5eed2541e26324620121022ed6c6d33a59cc16d37ad9ba54230696bd5424b8931c2a68ce76b0dbbc222f6500000000
Size: 226 bytes.
👉 Learn more about transaction structures
2. Weight Units (wu): SegWit’s Efficiency Metric
Introduced in BIP 141, Weight Units optimize block space by discounting witness data (signatures) to incentivize SegWit adoption.
Calculation Formula:
| Transaction Component | Multiplier |
|---|---|
| Version, Inputs, Outputs, Locktime | ×4 |
| Witness Data (Marker, Flag, Signatures) | ×1 |
Example:
For the 226-byte transaction above:
- Non-witness data: 116 bytes × 4 = 464
- Witness data: 110 bytes × 1 = 110
- Total Weight: 574 wu.
Purpose:
- Ensures blocks respect the 4 million weight unit limit (~1 MB non-witness + 3 MB witness data).
3. Virtual Bytes (vB): Bridging Legacy and SegWit
Virtual Bytes normalize transaction sizing for feerate comparisons by converting weight units into a byte-equivalent metric.
Key Points:
- vSize = Weight ÷ 4
- Discounts witness data by 75% (multiplier of 0.25).
- Legacy transactions: 1 byte = 1 vB.
- Block capacity: 1,000,000 vB.
Example:
Same transaction:
- Non-witness: 116 × 1 = 116
- Witness: 110 × 0.25 = 27.5
- vSize: 143.5 vB.
👉 Compare transaction fees effectively
Why Two Metrics? Weight vs. Virtual Bytes
Weight Units (wu):
- Integer-based for consensus-critical calculations (avoids floating-point errors).
- Used internally by nodes.
Virtual Bytes (vB):
- User-friendly for feerate comparisons (e.g., sat/vB).
- Aligns with legacy "sat/byte" conventions.
"Weight is an integer. We only use integers in consensus code."
— Pieter Wuille, Bitcoin Core Developer
FAQs
Q1: How does SegWit reduce transaction fees?
A: By discounting witness data (75% smaller in vB), transactions occupy less block space, lowering fees.
Q2: Can a transaction’s vSize exceed its byte size?
A: No. vSize is always ≤ byte size due to witness discounts.
Q3: Why was the block size limit changed from bytes to weight?
A: To enable SegWit’s scalability benefits while maintaining backward compatibility.
Q4: How do I calculate fees using vB?
A: Multiply your desired sat/vB rate by the transaction’s vSize (e.g., 143.5 vB × 10 sat/vB = 1,435 sats).
Q5: Are non-SegWit transactions penalized?
A: Indirectly—they lack witness discounts, making them costlier per byte of block space.
Key Takeaways
- Bytes: Raw data size.
- Weight Units: SegWit’s integer-based block space metric.
- Virtual Bytes: Human-friendly fee comparison tool.
By mastering these concepts, you can optimize transaction costs and contribute to Bitcoin’s scalability.