Bitcoin Block structure explained with examples

Follow and share now!

The byte sequence Block is the core element of encrypted currencies like Bitcoin. Please read this and the underlying posts, if you want to learn more about Blocks to understand the simple but brilliant underlying technology of encrypted currencies. If you have additional questions, send an email to [email protected] or use the simple contact form. Don’t forget to join the newsletter to the right to stay always up-to-date.

What does a byte sequence mean?

When you are not into computer, you may don’t know how to image such a Block. Please read first the article about the computer basics.

What is the purpose of a Block?

The transition of Bitcoin by wallet user is stored in Transactions. The major function of a Block is to store these unconfirmed Transactions to prove the money flow.

Where are Blocks stored?

The base of all available bitcoin clients is the application bitcoind, the worldwide first encrypted currency client. The main job of this software is maintenance the so-called Blockchain, the database containing all Blocks. bitcoind writes current all Blocks in the subdirectory blocks in  the configuration directory in files with the file name pattern blk<number of five digits, starting at 00000>.dat. All files have around 128 MiB of size. The storage of the Blockchain in one stream is no problem, since Blocks usual become only appended to the chain (one exception is, the chain become forked temporary if two clients find two Blocks to nearly the same time, one of these forks become thrown away later).

Who generates new Blocks?

bitcoind provides enough information to start searching for new Blocks. People searching for Blocks are called Miners. In fact, searching for a Block is in real searching for a Block Header (the reason is described here). Since it is today very hard to find a Block, Miners connect to pools. These share all data for building new Block Headers between connected Miners. When a matching Block Header is found, the pool submits the whole Block to their Bitcoin Client that adds the Block to the Blockchain and start sharing them with other connected clients in the peer-to-peer-network.

When becomes a Block Header accepted?

The Header of Blocks have to fulfill some rules to become accepted by the bitcoin clients. The most important is a challenge. A hash function, in case of Bitcoin SHA-256 twice times, that generates an unpredictable byte sequence from the Block Header, must be read as number smaller than a target number, that changes around all two weeks (after each 2016 Blocks), so that the next 2016 Blocks are found in around the next two weeks (around one Block all ten minutes).

Why searching Miners for new Block Headers?

Solo miners or Pools that construct new Blocks from matching Block Headers also construct the first Transaction of the Block, the so-called Coinbase Transaction. This Transaction regulates the access to the sum of the fee and the Block reward for finding the Block. The pool creates a successive Transaction to share this amount with the Miners, basing on their works. This is only possible after 100 new attached Blocks, cause of the above mentioned Blockchain fork.

  • These fees are just the sum of all fees of all Transactions in the Block.
  • The Block Reward is the way of initial generating coins. It started with 50 Bitcoin and halves each 210.000 found Blocks for advantage of early supporters. 210.000 Block become found in about four years. It is 12.5 Bitcoin to time of writing this article and will reach zero after generating all 21 million coins.

What is the Block height?

The Block height is the number of the Block in the Blockchain. The first Block has the height zero, the second one one, the third one two and so on.

Block height and confirmations:

A Transaction that is not yet stored in a block is called an unconfirmed Transaction. When a Transaction become stored in a Block, it gets one confirmation. Each later to the chain added Block increments the confirmation by one, since it becomes harder to change a Block, the more Blocks are attached behind.

What is the Genesis Block?

The Block with the height zero is called the Genesis Block. The Coinbase Transaction of the Genesis Block of Bitcoin contains the headline of a newspaper of the same day (in the main chain of The Times at 2009-01-03), so it became practice to do the same on creating own encrypted currency Blockchains.

Byte structure explanation:

NameSize in Bytes (Actual size of the first block)Data of first BlockDescription
Magic no4 (4)f9beb4d9

That is not really part of the Block, bitcoind writes these Magic Number in the local Blockchain files. So the submit command of bitcoind expect for example the new Block without this one.

Blocksize4 (4)1d010000

The size of the Block without this field. This field ends in the first Block on Byte 7, the next Block starts at 0x125 (293), hence there are 0x11D (285) Byte between.

Blockheader80 (80)010000000000000...

Read this article for detailed analyze.

Transaction counter1 to 9 (1)01

The Block contains 1 Transaction. That is the minimum, since each Block need a Coinbase Transaction.

transactions1+ (204)010000000100000...

Read this article for detailed analyze.

Magic no+4+f9beb4d9...

The start of the next Block...

Bitcoin Block Bytes example:

See this example bytes of the first mined Bitcoin Block ever:

:~$ xxd .bitcoin/blocks/blk00000.dat | head -n 19
00000000: f9be b4d9 1d01 0000 0100 0000 0000 0000 ................
00000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000020: 0000 0000 0000 0000 0000 0000 3ba3 edfd ............;...
00000030: 7a7b 12b2 7ac7 2c3e 6776 8f61 7fc8 1bc3 z{..z.,>gv.a....
00000040: 888a 5132 3a9f b8aa 4b1e 5e4a 29ab 5f49 ..Q2:...K.^J)._I
00000050: ffff 001d 1dac 2b7c 0101 0000 0001 0000 ......+|........
00000060: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000070: 0000 0000 0000 0000 0000 0000 0000 ffff ................
00000080: ffff 4d04 ffff 001d 0104 4554 6865 2054 ..M.......EThe T
00000090: 696d 6573 2030 332f 4a61 6e2f 3230 3039 imes 03/Jan/2009
000000a0: 2043 6861 6e63 656c 6c6f 7220 6f6e 2062 Chancellor on b
000000b0: 7269 6e6b 206f 6620 7365 636f 6e64 2062 rink of second b
000000c0: 6169 6c6f 7574 2066 6f72 2062 616e 6b73 ailout for banks
000000d0: ffff ffff 0100 f205 2a01 0000 0043 4104 ........*....CA.
000000e0: 678a fdb0 fe55 4827 1967 f1a6 7130 b710 g....UH'.g..q0..
000000f0: 5cd6 a828 e039 09a6 7962 e0ea 1f61 deb6 \..(.9..yb...a..
00000100: 49f6 bc3f 4cef 38c4 f355 04e5 1ec1 12de I..?L.8..U......
00000110: 5c38 4df7 ba0b 8d57 8a4c 702b 6bf1 1d5f \8M....W.Lp+k.._
00000120: ac00 0000 00f9 beb4 d9d7 0000 0001 0000 ................

xxd is a hex viewer, preinstalled on most Linux distributes. It shows on default on the left the hexadecimal address, then the next 16 Bytes in hexadecimal. On the right is the ASCII representation of the Bytes in the same order or a dot, if it is not symbolic or the most significant Bit is set, respectively. head takes the input and put out only a specified line or Byte count, in this case the first 19 lines.

This is the full hexadecimal part in one line:


Here are the groups, basing on the description above:

  • f9beb4d9
  • 1d010000
  • 0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c
  • 01
  • 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64
  • f9beb4d9d7000000010000

Post Your Comment Here

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