Ethereum: SegWit transaction fee/byte

Ethereum SegWit Transaction Fee and Byte Calculation

As the popularity of Ethereum and its use cases continues to grow, understanding the complexity of transactions is essential for both developers and users. In this article, we will look at how Ethereum’s Segregated Witness (SegWit) implementation affects transaction fees and bytes.

From Wit Basics

SegWit is a minor update to the Bitcoin protocol that allows for more efficient use of bandwidth and reduces the size of transactions, while maintaining their security and functionality. When a new transaction is broadcast to the network, it is split into smaller segments called Segments, which are then combined into a single block.

Transaction Fees

Ethereum’s SegWit implementation changes the way transaction fees are calculated. A key aspect of this change is the use of
Witness Data, which allows miners to validate and verify transaction results without having to store all the data in memory.

In traditional Bitcoin, each output is verified separately, with a unique timestamp and block hash as proof. In contrast, SegWit outputs are considered “spendable” if they meet specific conditions, including meeting the minimum 50-byte requirement for calculating the fee. If an output does not spend enough to cover its own fees, it is
unspent

, which affects transaction fees.

Transaction Fee Calculation

To understand how this works, let’s consider a simple example:

  • You set a fee of $1,000 for a transaction.
  • The block has 500 bytes of raw transaction data, but no witness data (i.e. the transaction itself contains no unique information to verify).
  • Since the production does not spend enough to cover its own fees, it is not spent.

Fee Calculation

For this scenario:

  • The sender sends a SegWit transaction with 500 bytes of raw transaction data.
  • The block has no witness data (the transaction itself is not verified).

Since the output does not meet the minimum requirements for fee calculation, it
is not spent, and its “fee” remains $1000.

Witness Data

Now, let’s consider an example where the output contains witness data:

  • You set $2000 as the fee.
  • The block has 500 bytes of raw transaction data, which contains unique witness data (e.g., a cryptographic hash).
  • This witness data ensures that the transaction is valid and meets all conditions.

In this case:

  • The sender sends a SegWit transaction with 500 bytes of raw transaction data containing witness data.
  • Since the result meets the minimum requirements for calculating the fee, it is spent by default.

Fee Calculation with Witness Data

Ethereum: SegWit transaction fee/byte

For this scenario:

  • The sender sends a SegWit transaction with 500 bytes of raw transaction data containing unique witness data (fee of $2000).
  • The block has no witness data (the transaction itself is not verified).

Since the result meets the minimum requirements for calculating the fee, its “fee” remains $2000.

Byte Calculation

The number of bytes of a transaction refers to the total size of all bytes in the transaction. When calculating fees, we need to consider both the raw transaction data and the witness data.

  • Raw transaction data: 500 bytes
  • Witness data (unspent): 0 bytes
  • Total bytes = 500 bytes

Conclusion

In conclusion:

  • Without witness data, transaction results that do not meet the minimum requirements for calculating fees will not be spent.
  • With witness data, transactions are guaranteed to be valid and will always have a certain amount of “fee”.
  • The number of bytes of a transaction only takes into account the raw transaction data. Witness data does not affect the total byte size.

Leave a Reply

Your email address will not be published. Required fields are marked *

More Articles & Posts