Calculating SegWit Transaction Fees in Bytes: A Step-by-Step Guide
As a developer building applications on the Ethereum network using Solidity, you are likely familiar with the concept of transaction fees and SegWit. In this article, we’ll break down how to calculate the total fee for multiple Segwit transactions, including inputs and outputs, taking into account the 100 Sat per byte rate.
What is SegWit?
SegWit (Small Ethereum Weight) is a version of the Ethereum Consensus Protocol that allows for more flexible transaction size limits. It was designed to improve performance and scalability by reducing the overhead associated with larger transactions.
Calculating Fees in Bytes: A Formulaic Approach
To calculate the total fee for multiple Segwit transactions, we can use the following formula:
Total Fee = (Number of Inputs Size of Input) + (Number of Outputs Size of Output)
Since we’re dealing with SegWit transactions, we need to consider the size of each input and output separately. For a single transaction, the size is typically in bytes.
Input Sizes
Let’s assume you have two separate inputs and two separate outputs for your Segwit transactions. The sizes are as follows:
- Input 1: 1000 bytes (e.g., a wide image);
- Input 2: 500 bytes
- Output 1: 20 bytes (e.g., a small string)
- Output 2: 50 bytes
Output Sizes
For the output transactions, let’s assume you have two separate outputs with sizes:
- Output 3: 10 bytes
- Output 4: 30 bytes
Calculating Fees
Now that we have all the necessary values, let’s plug them into our formula:
Total Fee = (2 Inputs 1000 bytes) + (2 Outputs 20 bytes)
= (2000) + (40)
= 2040 bytes
To convert this to Sat, we divide by 8 (since 1 byte = 8 Sat):
Total Fee = 2040 / 8 ≈ 256.5 Sat
Example Use Case
Suppose you’re building a smart contract that requires two inputs and two outputs for each transaction. The sizes of the inputs are 1000 bytes, 500 bytes, 20 bytes, and 10 bytes, while the sizes of the outputs are 50 bytes, 30 bytes, 20 bytes, and 40 bytes.
Using our formula, we get:
Total Fee = (2 Inputs 1000) + (2 Outputs 20)
= (2000) + (40)
= 2040 bytes
The total fee would be approximately 256.5 SAT per byte.
Conclusion

In conclusion, calculating SegWit transaction fees in bytes can be a straightforward process using the formula: Total Fee = (Number of Inputs Size of Input) + (Number of Outputs Size of Output). By understanding how to calculate the sizes of inputs and outputs separately, you’ll be able to accurately estimate your transaction fees for multiple Segwit transactions on the Ethereum network.
