If all transactions in a block were spending one p2tr output using the key-path spend and sending to a p2tr output, how many of these transactions could we fit in a single block?
1 Answer
For a transaction spending a single p2tr output via the key-path and creating a single p2tr output, we would construct a transaction with the following fields:
version (4 bytes)
witness marker (1 byte)
witness flag (1 byte)
input count (1 byte)
inputs (41 bytes)
output count (1 byte)
outputs (43 bytes)
witness stacks (as many as input count)
witness item count (1 byte)
witness items (65 bytes)
locktime (4 bytes)
For more details and to understand how the numbers above were chosen, make sure to read What is the weight of a P2TR input?.
This gives us a raw byte size of: (4 + 1 + 1 + 1 + 41 + 1 + 43 + 1 + 65 + 4) = 162 bytes
. However, post-segwit, block limits are no longer measured in bytes but in weight units.
To calculate the weight units for our transaction, recall that each non-witness byte is counted as 4 weight units and each witness byte is counted as one weight unit: (94) x 4 WU + (68) x 1 WU = 444 WU
.
With a blockweight limit of 4M WU, we could fit 9,009 of our simple transactions in a single block (4M WUs / 444 WUs per tx = 9,009 txs
).
Furthermore, each additional p2tr input adds 230 WU and each additional p2tr output adds 172 WU to the transaction. A more realistic transaction would be a 2-input, 2-output transaction with a total weight of 846 WU (444 + 230 + 172)
, of which we could fit 4,728 in a single block.