Ethereum: SegWit transaction fee/byte

Ethereum SegWit Transaction Fee and Byte Calculation

As the popularity of Ethereum and its applications continues to grow, understanding the intricacies of transactions is essential for both developers and users. In this article, we will delve into how Ethereum’s Segregated Witness (SegWit) implementation impacts transaction fees and bytes.

FromWit Basics

SegWit is a lightweight 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 divided 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

Ethereum: SegWit transaction fee/byte

, which allows miners to validate and verify the results of transactions without having to store all the data in memory.

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

, which affects transaction fees.

Calculating the transaction fee

To understand how this works, consider a simple example:

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

Calculating the fee

In this scenario:

  • The sender sends a SegWit transaction with 500-byte 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 calculating the fee, it
is not spent and its “fee” remains at $1,000.

Witness Data

Now consider an example where the output contains witness data:

  • You have a fee set at $2,000.
  • 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 output meets the minimum requirements for calculating the fees, it is spent by default.

Calculating Fees with Witness Data

In this scenario:

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

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

Calculating Bytes

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

To sum up:

  • Without witness data, transaction outputs 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 transaction byte count includes only the raw transaction data. Witness data does not affect the total byte size.

Leave a Comment

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