# Transaction Size

Bytes, Weight, and Virtual Bytes

You can measure the size of a bitcoin transaction in 3 ways:

1. Bytes (b) – Transaction size on disk.
2. Weight Units (wu) – For fitting transactions in to a block.
3. Virtual Bytes (vB) – For comparing fee rates between transactions.

Bytes is the most straightforward unit. It's used for measuring any amount of data on a computer.

Weight Units and Virtual Bytes are measurements unique to bitcoin. They both measure the size of a transaction in terms of bytes too, but they give a discount to some parts of the transaction data and are used when calculating how many transactions can fit inside a block.

Transaction Splitter

## 1. Bytes (b)

This is the natural way to measure the size of a transaction. It's just a transaction's actual size in terms of how many bytes of space it takes up.

Bytes are used when measuring how big a transaction is when it's being sent across the network, or how much space it takes up on disk (e.g. when stored in blockchain files).

Measuring the size of a transaction in bytes was more important when the block size limit was also measured in bytes (1,000,000 bytes, or 1 megabyte). However, the block size limit is now based on weight instead.

### Example

Size: 226 bytes

There are 226 bytes in this transaction.

You can check this for yourself, because every 2 hexadecimal characters represents 1 byte.

#### Typical transaction sizes

The size of a transaction in bytes mostly depends on how many inputs and outputs are in the transaction. Here are the average sizes for typical transactions (with standard P2PKH locking scripts on the outputs):

• Inputs: 1, Outputs: 1 = 191 or 192 bytes
• Inputs: 1, Outputs: 2 = 225 or 226 bytes (most common)
• Inputs: 2, Outputs: 1 = 338 or 339 bytes
• Inputs: 2, Outputs: 2 = 373 or 374 bytes (very common)

The more inputs and outputs there are in a transaction, the bigger it gets.

There is no limit to how big a transaction can be in terms of bytes, other than the fact that it needs to be able to fit inside a block.

## 2. Weight Units (wu)

BIP 141

Every transaction has a weight measurement. This measurement was introduced in the segregated witness upgrade. A transaction's weight is calculated by multiplying the size (in bytes) of different parts of the transaction by either 4 or 1:

Field Multiplier
version x4
marker x1
flag x1
input x4
output x4
witness x1
locktime x4

This therefore gives a discount to the witness data.

### Example

Size: 226 bytes

Weight: 574 weight units (116 x 4 + 110 x 1)

There are 226 bytes in this transaction. Out of those, 116 bytes are non-witness data so they get multiplied by 4, and 110 bytes are witness data so they get multiplied by 1. Add those together and you get 574 weight units.

### Block Limit (4,000,000 weight units)

The weight measurement is important because blocks can hold up to 4,000,000 weight units of transaction data.

So when miners fill up their candidate blocks with transactions, they use transaction weight to determine how many transactions they can fit in their block.

Using bytes for transaction sizes and the block limit was more straightforward. But this new weight measurement introduces fairness to the cost of spending outputs.

### Why does witness data weigh less?

Because it helps to bring more of a balance between the cost of creating an output and the cost of spending an output (in terms of transaction fees).

The amount of data required to unlock an output (i.e. signature data) is unfairly larger than the amount of data required to put a lock on an output in the first place. So the new weight measurement brings the "size" of outputs and inputs in a transaction more in line with each other.

## 3. Virtual Bytes (vBytes, vB)

The virtual size of a transaction is the same as its weight divided by 4.

Or to put it another way, instead of multiplying some parts of a transaction by 4 to create a discount for the witness data, you discount the witness data directly by multiplying it by 0.25 instead:

Field Multiplier
version x1
marker x0.25
flag x0.25
input x1
output x1
witness x0.25
locktime x1

So "weight" and "virtual size" provide the same measurement, just with different units. But using virtual bytes makes it easier to compare the fee rate of new segwit transactions with the fee rate of legacy transactions (which had previously used sats-per-byte).

A legacy transaction will be the same size in bytes as it is in vbytes.

A block can hold 1,000,000 virtual bytes.

### Example

Size: 226 bytes

vSize: 143.50 virtual bytes (116 x 1 + 110 x 0.25)

There are 226 bytes in this transaction. Out of those, 116 bytes are non-witness data so they get multiplied by 1, and 110 bytes are witness data so they get multiplied by 0.25. Add those together and you get 143.50 virtual bytes.

As you can see, the weight and vsize calculations work in the same way.

### Why do we use vbytes?

So why have both weight and vbytes? Why not calculate the weight of a transaction by multiplying some parts by 0.25 and just use that instead?

In other words, why have two measurements that do the same thing?

You see, working with fractional numbers on computers can often lead to rounding errors, which is why in Bitcoin we prefer to work with whole numbers when performing critically important calculations. Integer arithmetic always returns consistent and reliable results, whereas floating point arithmetic does not.

So in summary:

• Weight Units — Used internally when working out how many transactions can fit in to a block.
• Virtual Bytes — Used by humans when comparing the different fee rates on transactions.