Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
More About Block Header | Blocks and Transactions
course content

Contenido del Curso

Introduction to Blockchain

More About Block HeaderMore About Block Header

Before we can proceed to exploring the block header in details, we should first understand the difference between big endian and little endian formats.

Little Endian and Big Endian

First, we have to understand what endianness actually means.

Endianness refers to the order in which bytes (each byte is equal to 8 bits) are arranged within larger data types in computer memory.

Big endian format stores the most significant byte first, which aligns with how humans typically read numbers. Let's use the decimal number 234567890 as an example and convert it to hexadecimal and binary using Python and output the results:

Since computers store integers using a whole number of bytes, and each 2 hex digits correspond to one byte, we need an even number of digits. The hex representation of our number, 0xDFB38D2, contains 7 digits, so we need to add zero 0 to the left. The resulting number, 0x0DFB38D2, now has 8 hex digits (fits exactly 4 bytes) and the same value.

Similarly, our binary number has 28 bits, and every 8 bits correspond to 1 byte, so we need to the number of bits divisible by 8 adding 4 zeros 0 to the left. The resulting number, 0b00001101111110110011100011010010, now has 32 bits (fits exactly 4 bytes) and the same value.

Using Python, we got the big endian format, which we would also get if we converted manually, and our number looks as follows:

  • 0x0DFB38D2 in hex;
  • 0b00001101111110110011100011010010 in binary.

Let's take a look at the table below for to understand the big endian format:

Byte 1 Byte 2 Byte 3 Byte 4
Base 16 0D FB 38 D2
Base 2 00001101 11111011 00111000 11010010

Conversely, little endian format stores the least significant byte first, reversing the intuitive order:

Byte 4 Byte 3 Byte 2 Byte 1
Base 16 D2 38 FB 0D
Base 2 11010010 00111000 11111011 00001101

As you can see, our number in little endian format looks as follows:

  • 0xD238FB0D in hex;
  • 0b11010010001110001111101100001101 in binary.

Back to Block Header

To recap, the header is exactly 80 bytes containing six data fields, each of them being in little endian format. Let's now take a look at the header of block 645536:

000000205873757623f61cf57d122d3c18a877c8628f3193d2f9060000000000000000005c6b6c678a85005e91647f022798a27fd4bf5e07a877115ae7691373de4f9e912b80475fea0710179052dc97
Version
Previous hash
Merkle root
Timestamp
Bits
Nonce

Since the block header takes up exactly 80 bytes, there are exactly 160 hex digits (each byte corresponds to 2 hex digits). The Version field, for example, takes up 4 bytes, so there are 8 hex digits.

Here is the detailed info about this block in the explorer:

The fields here are shown in big endian format. Let's inspect the Bits field, for example, and compare it with its representation in the block header. Its hex representation is 0x171007ea in big endian format:

Byte 1 Byte 2 Byte 3 Byte 4
Base 16 17 10 07 ea

If we convert it to little endian format, it will look as follows:

Byte 4 Byte 3 Byte 2 Byte 1
Base 16 ea 07 10 17

As you can see, that's exactly what we had in the block header.

What does "endianness" refer to in the context of blockchain and computer systems?

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 2. Capítulo 3
course content

Contenido del Curso

Introduction to Blockchain

More About Block HeaderMore About Block Header

Before we can proceed to exploring the block header in details, we should first understand the difference between big endian and little endian formats.

Little Endian and Big Endian

First, we have to understand what endianness actually means.

Endianness refers to the order in which bytes (each byte is equal to 8 bits) are arranged within larger data types in computer memory.

Big endian format stores the most significant byte first, which aligns with how humans typically read numbers. Let's use the decimal number 234567890 as an example and convert it to hexadecimal and binary using Python and output the results:

Since computers store integers using a whole number of bytes, and each 2 hex digits correspond to one byte, we need an even number of digits. The hex representation of our number, 0xDFB38D2, contains 7 digits, so we need to add zero 0 to the left. The resulting number, 0x0DFB38D2, now has 8 hex digits (fits exactly 4 bytes) and the same value.

Similarly, our binary number has 28 bits, and every 8 bits correspond to 1 byte, so we need to the number of bits divisible by 8 adding 4 zeros 0 to the left. The resulting number, 0b00001101111110110011100011010010, now has 32 bits (fits exactly 4 bytes) and the same value.

Using Python, we got the big endian format, which we would also get if we converted manually, and our number looks as follows:

  • 0x0DFB38D2 in hex;
  • 0b00001101111110110011100011010010 in binary.

Let's take a look at the table below for to understand the big endian format:

Byte 1 Byte 2 Byte 3 Byte 4
Base 16 0D FB 38 D2
Base 2 00001101 11111011 00111000 11010010

Conversely, little endian format stores the least significant byte first, reversing the intuitive order:

Byte 4 Byte 3 Byte 2 Byte 1
Base 16 D2 38 FB 0D
Base 2 11010010 00111000 11111011 00001101

As you can see, our number in little endian format looks as follows:

  • 0xD238FB0D in hex;
  • 0b11010010001110001111101100001101 in binary.

Back to Block Header

To recap, the header is exactly 80 bytes containing six data fields, each of them being in little endian format. Let's now take a look at the header of block 645536:

000000205873757623f61cf57d122d3c18a877c8628f3193d2f9060000000000000000005c6b6c678a85005e91647f022798a27fd4bf5e07a877115ae7691373de4f9e912b80475fea0710179052dc97
Version
Previous hash
Merkle root
Timestamp
Bits
Nonce

Since the block header takes up exactly 80 bytes, there are exactly 160 hex digits (each byte corresponds to 2 hex digits). The Version field, for example, takes up 4 bytes, so there are 8 hex digits.

Here is the detailed info about this block in the explorer:

The fields here are shown in big endian format. Let's inspect the Bits field, for example, and compare it with its representation in the block header. Its hex representation is 0x171007ea in big endian format:

Byte 1 Byte 2 Byte 3 Byte 4
Base 16 17 10 07 ea

If we convert it to little endian format, it will look as follows:

Byte 4 Byte 3 Byte 2 Byte 1
Base 16 ea 07 10 17

As you can see, that's exactly what we had in the block header.

What does "endianness" refer to in the context of blockchain and computer systems?

Selecciona la respuesta correcta

¿Todo estuvo claro?

Sección 2. Capítulo 3
some-alt