Hello everyone! I'm Soichi Sumi (@soichisumi), a backend engineer. Recently, I researched how to determine transaction fees for blockchain transactions and decided to document my findings in this blog post.
In Proof-of-Work (PoW) blockchains, transaction fees determine how quickly a transaction gets included in a block. Higher fees generally lead to faster inclusion, but as users, we want to keep costs as low as possible. This article explains how transactions are selected for inclusion in Bitcoin-based blockchains and how to set fees optimally to balance speed and cost efficiency.
The Journey of a Bitcoin Transaction: From Creation to Block Inclusion
A Bitcoin transaction goes through four key stages before being added to a block:
Transaction Construction
The sender builds an unsigned transaction containing:
- Recipient address
- Unspent transaction outputs (UTXOs)
- Amount to send
- Transaction fee
- The transaction is then signed to unlock the UTXOs.
Broadcasting
- The signed transaction is sent to multiple nodes in the Bitcoin network.
Validation
Nodes verify the transaction by checking:
- Correct syntax and data structure
- Whether it’s already included in a block
- Validity of input UTXOs (existence and non-duplication)
- Proper unlocking of UTXOs
- Valid transactions enter the mempool (a waiting area for unconfirmed transactions).
Mining
- Miners select transactions from the mempool to include in the next block.
- Priority is typically given to transactions with the highest fee rate (satoshi per byte, or s/b).
👉 Discover how miners prioritize transactions
How to Set Fees for Fast and Cheap Confirmations
Since miners prioritize transactions with higher fee rates, your transaction's position in the mempool depends on its s/b ratio. Here’s how to optimize fees:
1. Understand Network Conditions
Fee rates fluctuate based on:
- Time of day: Higher traffic during peak hours (e.g., midnight–early morning).
- Market activity: Spikes during bull runs (e.g., Bitcoin’s 2018 bubble).
2. Use Fee Estimation Tools
Platforms like Earn Bitcoin provide real-time data on:
- Current fee rates.
- Expected confirmation times (e.g., "50 sat/b for 1-block confirmation").
- Automated tools (e.g., Ginco’s fee API) adjust fees dynamically for optimal speed.
3. Manual Fee Adjustment (Advanced)
If you override automatic fees, refer to:
- Live mempool data (Johoe's Mempool Stats).
- Historical trends to avoid overpaying.
👉 Learn how to calculate satoshi per byte
FAQs: Bitcoin Transaction Fees
1. What’s the average fee for a Bitcoin transaction?
- Fees range from 1–500 sat/b, depending on network congestion.
2. How can I reduce my transaction fees?
- Send transactions during off-peak hours (e.g., midday).
- Use SegWit addresses to lower transaction size.
3. Why is my transaction stuck in the mempool?
Low fee rates delay confirmations. Either:
- Wait for network activity to drop.
- Replace-by-Fee (RBF) to increase the fee (if enabled).
4. Can I cancel an unconfirmed transaction?
- No, but some wallets support child-pays-for-parent (CPFP) to speed it up.
Key Takeaways
- Miners prioritize transactions with the highest fee rate (s/b).
- Use tools like Earn Bitcoin or dynamic fee APIs to optimize costs.
- Adjust fees based on time of day and network congestion.
References
Enjoyed this guide? Support our engineering team’s work!