Transaction Structure

At a high level, a Bitcoin transaction has five main components:

  • Version
  • Marker & Flag
  • Inputs
  • Outputs
  • Locktime

Let's analyze a real transaction from the Bitcoin blockchain to understand these components better.

We'll use transaction ID 89699cce128...c5a497fbae881 from block 877417 as an example.

To get the raw transaction data, run:

bash
$ bitcoin-cli getrawtransaction 89699cce128a694b4fb3be0e07ae0a9b63f0da1bc62fb3a4eb3c5a497fbae881

The output will be the serialized transaction format (A long hexadecimal string representing all transaction data).

text
010000000114e68f759adcfe66c6aa77d38dc0816cbecf3e9e12d76794f3f9e34c9b1a6e5e000000006b483045022100b18dd5124cf2fcd31af3747a55ed941867f781c340007d9d86dae9e04fa8933f02200bdf817b2e6122ba97b8de40541728ead3988df7462241d6ce70e0f6788e126c012102cd3dfbe89ebca9ee2cfeb5d36234c7d33bce1c329f8a0a318271a48fb9d259d2ffffffff0132aa3200000000002251205805e61a8cc830846e039fa137e791c65b489c9083d14d05a26caebb10d9bf7600000000

What is Serialization?

Serialization is the process of converting structured data into a compact format (in this case, a hex string) that can be easily stored and transmitted across the Bitcoin network.

You can explore this transaction's structure using the interactive tool below:

TransactionVersion
Structure
Version
4 bytes
Segwit (Optional)
Marker
1 byte
Flag
1 byte
Structure
Input Count
variable
Input Structure
Previous TXID
32 bytes
Output Index
4 bytes
ScriptSig Size
variable
ScriptSig
variable
Sequence
4 bytes
Structure
Output Count
variable
Output Structure
Amount
8 bytes
ScriptPubKey Size
variable
ScriptPubKey
variable
Structure
Witness
variable
Structure
Locktime
4 bytes

Size

4 bytes

Format

Little-Endian

Description

The version number for the transaction. Used to enable new features.

Example

02000000

Byte Visualization

02
Byte 1
00
Byte 2
00
Byte 3
00
Byte 4

In the following sections, we'll break down each component of the transaction structure in detail.

Suggest Edits