TeachMeBitcoin

Serialization Flip-Flop

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

Serialization Flip-Flop

To master Bitcoin development, you must memorize which fields are flipped and which are not. Failing to reverse the bytes in the right place will result in invalid transactions or "Transaction Not Found" errors.

1. The "Flipped" List (Little Endian)

These values must be reversed when moving between a human-readable hex string and raw binary:

2. The "Natural" List (Big Endian)

These values are copied "As-Is" and are not reversed:

3. The "Block ID" Trap

In Bitcoin, the "Block ID" is the Block Hash.

4. Scripts and Endianness

Bitcoin Script has its own rules.

5. Identifying the Flip

A quick way to tell if a hex string is Little Endian:

  1. Look at the trailing zeros.

  2. If the number is small (like 100), and you see 64 00 00 00, it is Little Endian.

  3. If you see 00 00 00 64, it is Big Endian.

Object Part of Object Endianness
Transaction Input Sequence Little
Transaction Unlocking Script Big (Natural)
Block Header Merkle Root Little

In the final section, we will build a Python Endianness Auditor.

☕ Help support TeachMeBitcoin

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:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!