View the Genesis Block

Posted by Justin O'Brien, David Harding

How to use hexdump to look at the Genesis Block

Requirements

What you'll learn

By the end of this tutorial, you'll see the first block on the Bitcoin blockchain, created by Satoshi Nakamoto. You'll also see how Bitcoin Core stores blocks on your disk.

Install 21

The Genesis Block

The first block on the Bitcoin blockchain—block 0—is called the Genesis Block. According to the timestamp in the block header, it was mined on 3 Jan 2009 at 18:15:05 UTC, although (as you'll learn) it contains more proof of work than we'd expect and the mining was only started on January 3rd.

Let's take a look at it on the disk of your computer by running the following commands:

cd ~/.bitcoin/blocks
hexdump -n 255 -C blk00000.dat

The cd command changes your directory into the Bitcoin Core block data directory. The hexdump command above displays the first 255 bytes of the file. It should look like this:

00000000  f9 be b4 d9 1d 01 00 00  01 00 00 00 00 00 00 00  |................|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 3b a3 ed fd  |............;...|
00000030  7a 7b 12 b2 7a c7 2c 3e  67 76 8f 61 7f c8 1b c3  |z{..z.,>gv.a....|
00000040  88 8a 51 32 3a 9f b8 aa  4b 1e 5e 4a 29 ab 5f 49  |..Q2:...K.^J)._I|
00000050  ff ff 00 1d 1d ac 2b 7c  01 01 00 00 00 01 00 00  |......+|........|
00000060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 ff ff  |................|
00000080  ff ff 4d 04 ff ff 00 1d  01 04 45 54 68 65 20 54  |..M.......EThe T|
00000090  69 6d 65 73 20 30 33 2f  4a 61 6e 2f 32 30 30 39  |imes 03/Jan/2009|
000000a0  20 43 68 61 6e 63 65 6c  6c 6f 72 20 6f 6e 20 62  | Chancellor on b|
000000b0  72 69 6e 6b 20 6f 66 20  73 65 63 6f 6e 64 20 62  |rink of second b|
000000c0  61 69 6c 6f 75 74 20 66  6f 72 20 62 61 6e 6b 73  |ailout for banks|
000000d0  ff ff ff ff 01 00 f2 05  2a 01 00 00 00 43 41 04  |........*....CA.|
000000e0  67 8a fd b0 fe 55 48 27  19 67 f1 a6 71 30 b7 10  |g....UH'.g..q0..|
000000f0  5c d6 a8 28 e0 39 09 a6  79 62 e0 ea 1f 61 de     |\..(.9..yb...a.|
000000ff

The output has three columns:

  1. The left side is the byte count; it starts at zero and increases by 16 bytes on each line except the last.

  2. The middle part is each byte with a space between it and the next byte. Bytes are represented here in hexadecimal which takes two characters to represent a single byte. When we refer to byte sequences below, we'll use the common prefix of 0x. For example, the first byte in the output is 0xf9.

  3. On the right is the ASCII text representation of the hexadecimal data. Bytes that don't map to displayable ASCII are shown as periods. Almost none of the data in the blockchain is ASCII, but Nakamoto left us a surprise here (see below for details).

Note the first four bytes, 0xf9beb4d9. This is called "Bitcoin's magic number", although it isn't really magical. It's just four arbitrary bytes chosen by Nakamoto as a byte sequence otherwise unlikely to appear in a Bitcoin datastream. In the block data files, these bytes identify the start of a new block but they aren't part of the block themselves. These bytes also start each message in the Bitcoin peer-to-peer network protocol to help clients tell when one message ends and another begins.

You'll note that the early part of the block contains many zero bytes (0x00). That's because the Genesis Block, unlike every other Bitcoin block, doesn't reference a previous block—it just references a long string of zeroes. This is truly the beginning of the Bitcoin blockchain.

Finally, in the ASCII text section, you'll see the message Nakamoto left us:

The Times 03/Jan/2009 Chancellor on brink of second bailout for banks

This was part of a special field in the special first transaction of a block, called a coinbase transaction. In Nakamoto's day, this field allowed miners to include up to 100 bytes of arbitrary data in each block they made. Today, that's been reduced to 97 bytes, but still most miners include a message of some sort in every block they make.

Nakamoto's message is especially important. It's the actual headline (although slightly garbled) of a real newspaper, the Financial Times, from the indicated date. This message, which may also express some of Nakamoto's frustration with the pre-Bitcoin financial system, provides extremely strong evidence that Nakamoto couldn't have mined his block earlier than the morning of January 3rd.

(Based on the second block on the blockchain, dated January 8th, it's likely that Nakamoto didn't actually finish mining the Genesis Block until a few days later.)

Why is this important? We also know that Nakamoto announced that the Bitcoin software was available on the 8th, and that there was another notable user (cryptographer Hal Finney) a few days later, so the proof that he didn't start mining until the 3rd shows that Nakamoto didn't attempt to mine all the early blocks himself in an attempt to create some sort of Ponzi scheme.

If you want to see more of the blockchain, replace the number 255 in the command above with a higher number—but beware, the blockchain is pretty boring for its first few ten thousand blocks.

Because the Genesis Block is unlike all other Bitcoin blocks, Nakamoto had to use custom code to mine it. In the next tutorial, we'll help you write your own CPU Bitcoin miner to re-create the exact same block Nakamoto mined as well as learn about what data regular miners include in their block headers.

Questions

Questions about hexdump and the Genesis Block

What block number is the Genesis Block?

Correct

Incorrect

Correct

Incorrect

Correct

Incorrect

Correct

Incorrect

Correct

Incorrect

How many characters would it take to display 16 bytes in hexadecimal?

Correct

Incorrect

Correct

Incorrect

Correct

Incorrect

Correct

Incorrect

Correct

Incorrect

What are Bitcoin's magic bytes?

Correct

Incorrect

Correct

Incorrect

Correct

Incorrect

Correct

Incorrect

Correct

Incorrect