Bitcoin Transactions explained – easy money storage examples

Follow and share now!

Transactions are a major part of encrypted currencies like Bitcoin. These store the money transfer from and to an Bitcoin address. Please read this whole post, to learn, how money in Bitcoin and similar is handled:

Purpose of a Bitcoin Transactions:

A Bitcoin Transaction is the way, Bitcoin stores money. It is primary a wrapper for two lists, containing the two sub-elements Input Transaction (Txin) and Output Transaction (Txout). The exact structure is described full detailed further below.

Where Bitcoin Transactions become stored:

Transactions are stored in the blockchain. A fresh new Bitcoin Transaction is called an unconfirmed Transaction. The Bitcoin client broadcast his new created Transactions to all other connected clients. Mining pools adding received unconfirmed Transactions to their work. When a miner of such a pool finds a new Block, the Block and the included Transactions become appended to the blockchain. So become an unconfirmed- a confirmed Transaction.

What are Transaction confirmations?

On paying Bitcoin to an automatic system, it may tell it waits for a certain number of confirmations. That is the count of the Block, containing the Transaction and all Blocks appended behind this Block in the Blockchain. So a confirmation count of three means, behind the Block with the Transaction are two other Blocks. The count will increment approximately each ten minutes by one, since miners find approximately each ten minutes a new Block.

Bitcoin Transaction format explanation:


The Bitcoin Transaction contains some basic attributes and two lists, containing the instances of the both elements Txin and Txout.

NameSize in BytesDescription
Version no4The Bitcoin Transaction structure version, current 0x01000000 in Little Endian.
Flag0 or 2Optional flag, always 0x0001 in Little Endian. Transaction contains Witnesses if present.
In-counter1 to 9The count of input transactions in the next field as VarInt data type.
list of inputsNot predictableOne input after another, see below.
Out-counter1 to 9The count of output transactions in the next field as VarInt.
list of outputsNot predictableOne output after another, see below.
WitnessesNot predictableOne witness per input, omitted if upper field Flag is missing.


Txin format:

The Input Transaction takes money from an Output Transaction of another Transaction and send them to the Output Transactions in the actual Transaction. It contains a reference to a transaction, the number of the Txout to refer in this Transaction and a script to prove, that you are allowed to take this money. For more information about Bitcoin Transaction validating, please read the corresponding article, especial this example.

NameSize in BytesDescription
Previous Transaction hash32The hash of the Transaction, containing the output to use, as usual SHA256 twice times. In the coinbase just zero (read below).
Previous Txout-index4The number of the output to use in the Transaction, referred in the previous field.
Txin-script length1 to 9The size in bytes of the next field, decoded as VarInt.
Txin-scriptSo much, as the previous field tells.The script to access the previous outputs. In a coinbase the numbers of Bytes to push + the Bytes of the actual Block height + anything you want

Txout format:

The Output Transaction is the target of the money. It contains just a field for the amount of the money and a script to regulate the access to the transferred money. Say, there are two girls, Kim and Sarah. Kims whole balance is just the sum of all outputs, she has access to. To send money to Sarah, Kim creates a new Transaction with inputs that access her output transaction and an output to access by Sarah. An input consumes the whole balance from an output, inputs are only allowed to refer to outputs, that was never referred by any input before.

A Txout, not referred by a Txin yet, is called unpaid, an already used Transaction paid. Kim may create a Transaction with outputs, giving only her access, to keep some coins of them, the inputs consume. So has Kim, for example, access to one output with one Bitcoin and transfers a half of a Bitcoin to Sarah, she will, ignoring taxes, create a transaction with one input to consume the Bitcoin and two outputs, one to access for Sarah and one to access for Kim. Please note, Sarah needs to check the outputs or send the money to her own output, it is easy to create an output with access for dozens of keys.

NameSize in BytesDescription
value8The number of Satoshi to transfer. 100.000.000 Satoshi are 1 BTC.
Txout-script length1 to 9The length of the next field in Bytes, decoded as VarInt.
Txout-scriptThe count is decoded in the previous field.The script to allow the coin recipient to access.

All starts with the Coinbase:

Each Block needs at least one Transaction, the Coinbase Transaction. This byte structure is always the first Transaction of a Block and contains one input and one or more output. The single input is the only different between a Coinbase- and a usual Transaction. This ones field of the referring output is zero, since the coins don’t come from an output. The input script field needs to start with the byte count of the block height, followed by the block height bytes. This later hotfix was need to make sure, miners don’t always mine with the exact same Coinbase Transaction to create multiple Transactions with the same hashes. The rest of the field become ignored, most miners put UTF-8 decoded texts into. The output prepares just the Block rewards for usage of the miner.

Byte structure examples:

Example #0

Below are the Bytes of the single Transaction of the Block with the height of zero, the so-called Genesis Block, of the main Bitcoin chain. It contains for obviously reasons no other Transaction and generated the world first Bitcoin:

Transactions example #0


  • 01000000
  • 01
  • 0000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d
  • 01
  • 0000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff
  • 01
  • 00f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac
  • 00000000
NameSize in Bytes (Current size)DataDescription
Version no4 (4)01000000Version 1
Flag0 or 2 (0)Not present
In-counter1 to 9 (1)01Txin count as VarInt, in this case 1
list of inputsNot predictable (68)00000000...The Txin, described below
Out-counter1 to 9 (1)01Txout count as VarInt, in this case 1
list of outputsNot predictable (76)00f2052a...The Txout, described below
WitnessesNot predictable (0)The Flag Bytes don't exist, so there are no Witnesses
lock_time4 (4)636f6e64See OP_CHECKLOCKTIMEVERIFY

Txin example #0


  • 000000000000000000000000000000000000000000000000000000000000000
  • ffffffff
  • 4d
  • 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73
    • 04ffff001d
    • 0104
    • 455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73
  • ffffffff
NameSize in Bytes (Current size)DataDescription
Previous Transaction hash32 (32)00000000...

The Transaction of the Txout, where the coins come from. It is in the Coinbase Transaction just 0.

Previous Txout-index4 (4)ffffffff

The index of the Txout in the Transaction of the field before.

Txin-script length1 to 9 (1)4d

The Byte count of the input script. In this case 154 in decimal.

Txin-script1+ (154)04ffff00...

The first instruction of the script of a input of a Coinbase Transaction needs today to push the Block Height of the containing Block. This later addition was needed to prevent miners from always using of the same Coinbase Transaction to prevent duplicate hashes. The rest of the input of a Coinbase Transaction gets ignored. Many miners write something as UTF-8 characters into the free space, in this case The Times 03/Jan/2009 Chancellor on brink of second bailout for banks.

sequence_no4 (4)ffffffff


  • The Bitcoin Script instructions 0x01 to 0x4b push exactly so many Bytes as the number of the instruction as one value in Big Endian onto stack. So the Stack will be at the end 0xffff001d 0x04 0x5468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f 6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73 <Pointer>. The last element is the UTF-8 represent of the text The Times 03/Jan/2009 Chancellor on brink of second bailout for banks. It became tradition to add the headline of a today newspaper in the Genesis Block of an encrypted currency Blockchain.

Txout example #0


  • 00f2052a01000000
  • 43
  • 4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac
    • 4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f
    • ac
NameSize in Bytes (Current size)DataDescription
value8 (8)00f2052a01000000

The number of Satoshi to transfer. This contains in the Coinbase Transaction the value of the Block reward and transaction fees. It is 0x000000012A05F200 in Big Endian, hence in decimal, the 50 BTC block reward.

Txout-script length1 to 9 (1)43

The Byte count of the next field as VarInt. It is 67 in decimal.

Txout-script1+ (67)04ffff00...

The script to allow the recipient of the coins to access them. The coins of a Coinbase Transaction can only accessed after at least 100 confirmations, since the Blockchain may fork temporary, if two matching Blocks was found simultaneity. One of these chains is thrown away later.

  • The Bitcoin Script in this output push these 65 (0x41) Bytes on the stack and executes OP_CHECKSIG (0xAC).

Post Your Comment Here

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