Anatomy of a Transaction
Anatomy of a Transaction
At its core, the Bitcoin ledger does not actually track "accounts" or "balances." Instead, it is a chain of transaction records. If you look at the raw bytes of a Bitcoin transaction, you will find that it is a highly structured, serialized package designed to safely pass cryptographic verification.
To understand how value moves across the network, we must break down the physical anatomical structure of a standard Bitcoin transaction.
πΊοΈ The Physical Schema of a Transaction
A raw Bitcoin transaction is simply a stream of hexadecimal bytes. When parsed by a node, these bytes represent exactly five main sections:
| Field Number | Field Name | Size (Bytes) | Description |
|---|---|---|---|
| 1 | Version | 4 | Indicates to nodes which validation rules to apply to the transaction. |
| 2 | Input Counter | 1β9 (VarInt) | Indicates how many transaction inputs are included in this transaction. |
| 3 | List of Inputs | Variable | A list of one or more inputs, containing OutPoints and unlocking scripts. |
| 4 | Output Counter | 1β9 (VarInt) | Indicates how many transaction outputs are included in this transaction. |
| 5 | List of Outputs | Variable | A list of one or more outputs, containing satoshi values and locking scripts. |
| 6 | nLockTime | 4 | An absolute timelock parameter indicating when the transaction is allowed to be mined. |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ANATOMY OF A TRANSACTION β
βββββββββββββ¬ββββββββββββββ¬ββββββββββββββββββ¬βββββββββββββ€
β Version β Inputs List β Outputs List β nLockTime β
β (4 Bytes) β (Variable) β (Variable) β (4 Bytes) β
βββββββββββββ΄ββββββββββββββ΄ββββββββββββββββββ΄βββββββββββββ
π Breaking Down the Main Sections
1. Version (4 Bytes)
The version field tells nodes which set of rules to use when validating this transaction. Currently, the most common version is 1 (legacy) or 2 (which enables relative timelocks using the nSequence field in inputs).
2. The Inputs List (Variable Size)
An input is a reference pointing to an unspent transaction output (UTXO) that was created in a previous transaction. * Because Bitcoin uses a UTXO model, you cannot simply say "spend \$5 from my balance." Instead, you must point to a specific "chunk" of bitcoin you received earlier, prove that you own it, and consume it entirely. * An input contains a cryptographic key (unlocking script) that satisfies the locking conditions of the output it is spending.
3. The Outputs List (Variable Size)
An output defines where the consumed bitcoins are going next. It contains two fields: * Value: The amount of satoshis being sent to this output. * ScriptPubKey (Locking Script): A computer program written in Bitcoinβs scripting language (Script) that defines the conditions required to spend this output in the future. Usually, this condition is "prove you have the private key corresponding to this public address."
4. nLockTime (4 Bytes)
The nLockTime field is a 4-byte parameter that acts as an absolute timelock:
* If nLockTime is set to 0, the transaction is immediately valid.
* If nLockTime is set to a number below 500,000,000, it is interpreted as a block height. The transaction cannot be mined until the blockchain reaches that height.
* If nLockTime is set to a number above 500,000,000, it is interpreted as a Unix timestamp. The transaction cannot be mined until that exact time has passed.
π The Chain of Spent Outputs
Because every input must reference a previous output, transactions form an unbroken, perfectly traceable genealogical tree stretching all the way back to Satoshi's Genesis Block:
[ Transaction 1 ]
βββ Output A (1.5 BTC) ββββΊ Spent by ββββΊ [ Transaction 2 ]
βββ Input A (1.5 BTC)
βββ Output B (1.2 BTC) βββΊ Spent by βββΊ [ Transaction 3 ]
βββ Output C (0.3 BTC) (Change)
By structuring transactions as explicit inputs and outputs rather than dynamic bank account balances, Bitcoin prevents double-spending mathematically, allows ultra-fast parallel transaction validation, and preserves absolute public auditability.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: