If you have had the pleasure of delving into the block chain, you may have come across the term magic number. This is the first 4 bytes of every block in the block chain and is defined as:
|Network||Magic value||Sent over wire as|
|main||0xD9B4BEF9||F9 BE B4 D9|
|testnet||0xDAB5BFFA||FA BF B5 DA|
|testnet3||0x0709110B||0B 11 09 07|
|namecoin||0xFEB4BEF9||F9 BE B4 FE|
Wikipedia states “Magic value indicating message origin network, and used to seek to next message when stream state is unknown.”
… and used to seek next message when stream state is unknown? Say what?
What this really means is that the “magic number”, which is not really magic at all is an identifier that allows programmers to understand when a block starts and when it ends. It is always fixed at the value 0xD9B4BEF9 and also doubles up to mean the block comes from the main or production network.
Where did they come from?
To understand where this came from, we need a history lesson in computing. These links do a superb job at explaining it:
If you felt that those links were TL;DR (too long; didn’t read), then the summary is that back in the old days, information was inserted at the start of all files to help the OS (Operating System) figure out what kind of file it is. This is partly why file extensions are not as important in a non windows environment.
The important bits
The magic number inside a block is not so magic but more like a constant that was chosen by none other that Satoshi Nakamoto himself to help identify the start of a block in the block chain.