5

I know bitcoin has a block chain that is from my best representation a list of blocks. I know the block holds many transactions. But i'm still very much lost as to what a block is and how a block can be the function of the transactions at the time prior to the block being solved and how a block can have any number of transactions prior to it being solved and locked in.

I'm also lost on the process of "solving" a block. I know it requires computers encrypting the transaction. If a block is multiple transaction would that imply that you have to solve all the transactions to get the block.

2

1 Answer 1

7

There are a lot of questions on the Bitcoin SE about blocks, but remarkably I couldn't find any that explicitly lay out what a block is.

A blocks has two things: A block header and a list of transactions.

Block:

  • Block Header
    • Version Number (4 byte integer)
    • Previous Block Id (32 byte hash)
    • Merkle Root (32 byte hash)
    • Time (4 byte integer)
    • Difficulty (4 byte integer)
    • Nonce (4 byte integer)
  • List of Transactions
    • Number of transactions in List
    • Tx1
    • Tx2
    • ...
    • TxN

In the block header part of the block:

  1. The version number is a parameter to help in updating how blocks are treated by the network.
  2. The reference to the hash of the previous block is what makes the group of blocks a "block chain".
  3. The merkle root is hash that can be used to prove that a transaction is in the block without providing all of the details of the block (this is a bit complicated, see this for more info).
  4. The time field is to show the network what time the block was solved at, and to help in calculating the difficulty parameter.
  5. The difficulty (or nBits as it is called in the code) is shorthand for how difficult it is to solve the block. Essentially, it encodes a target value, and the hash of the block (when treated as a 256 bit integer) must be below that target value to be considered solved.
  6. The nonce (number used once) is just an integer that miners can change repeatedly to hash the header and get a different result each time, hoping to get a hash that is below the difficulty value encoded by the previous parameter.

The list of transactions is fairly straightforward, it's just the number of transactions and then the transactions themselves concatenated together.

Take for example the genesis block. The raw bytes are:

0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c0101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000

When we break this up, we can see what is in it:

01000000                                                          // Version
0000000000000000000000000000000000000000000000000000000000000000  // Hash Previous Block
3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a  // Merkle Root
29ab5f49                                                          // Time
ffff001d                                                          // Difficulty
1dac2b7c                                                          // Nonce
01                                                                // Number of Transactions
 Tx1:
 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000

When you hash the block header of the genesis block, you get:

000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f

See how it starts with all these zeroes? That's because many many tries were taken (changing the nonce each time) until the miner was lucky enough to find a nonce that makes the block header hash to a low enough value (look at the hash as a hex encoded integer, with the most significant bits on the left, and the least significant on the right).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.