The question asked here displays the genesis block in pretty good detail. I am still trying to get a breakdown of some of the elements seen here (and some others not seen here):

  1. The Merkle Root
  2. Time
  3. Bits
  4. Nonce
  5. The Transaction Section:
    • Coinbase
    • scriptSig
    • scriptPubKey

It is still unclear to me where all these elements come from.

The Merkle Root, as I understand it, is basically a hash of many hashes (Good example here) - to create a Merkle Root you must start by taking a double SHA-256 hash of the byte streams of the transactions in the block .What is this data (the byte streams), what does it look like, and where does it come from? I think, to understand those questions, one should better understand the data found under "Example tx message" here.

After studying this data, I don't understand it completely either. I am unsure as to where the TxIn, TxOut, and OutPoint come from. What do they look like for the genesis block? I saw that one fellow had a similar question but it was never answered really (unless TxIn sequence is something totally different from just TxIn).

If the coinbase is "the first input of the first transaction" I think knowing more about TxIn and TxOut would explain what the coinbase for the genesis block looks like also, which is another thing I don't understand.

Can anyone explain or point me to what these bits of data look like for the genesis block?

  • 1
    for a technical in-depth explanation of these various things you'd be best off either crawling the bitcoin wiki or my personal favorite is the Developer GUide! For example the explanation of the Block Header with the Time, Bits, Nonce etc and more on the the Merkleroot – Ruben de Vries May 1 '14 at 8:36

Note that all hex numbers and hashes here and in the protocol are little endian. So the ones I show will look backwards from a lot of sites which show them in big endian format.

The Merkle Root

This is a way to combine all the hashes of the transaction together into 1 hash. To do this we first need the hashes of all the transactions. There is only one transaction in the genesis block so let's find its hash. This is based off of this format.

import hashlib

#version 1, uint32_t
version = "01000000"

#1 input transaction, var_int
tx_in_count = "01"

#the default for generation transactions since there is no transaction to use as output
OutPoint_hash = "0000000000000000000000000000000000000000000000000000000000000000" 

#also default for generation transactions, uint32_t
OutPoint_index = "ffffffff"

previous_output = OutPoint_hash + OutPoint_index

#77, var_int
script_length = "4d"

#The coinbase. In a regular transaction this would be the scriptSig, but unused in generation transactions.
#Satoshi inserted the headline of The Times to prove that mining did not start before Jan 3, 2009.
#???????EThe Times 03/Jan/2009 Chancellor on brink of second bailout for banks
signature_script = "04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73"

#final sequence, means it can't be replaced and is immediately locked, uint32_t
sequence = "ffffffff"

tx_in = previous_output + script_length + signature_script + sequence

#1 transaction output, var_int
tx_out_count = "01"

#5000000000 satoshis == 50 bitcoin, uint64_t
value = "00f2052a01000000"

#67 var_int
pk_script_length = "43"

#The scriptPubKey saying where the coins are going.
pk_script = "4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac"
#We can decode this.
#41 push the next 65 bytes onto the stack
#04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f the 65 bytes that get pushed onto the stack
#ac OP_CHECKSIG
#This is a pay-to-pubkey output, which is the default for generation transactions.

tx_out = value + pk_script_length + pk_script

#immediately locked, uint32_t
lock_time = "00000000"

transaction = version + tx_in_count + tx_in + tx_out_count + tx_out + lock_time

transaction_bin = transaction.decode("hex")
transaction_hash_bin = hashlib.sha256(hashlib.sha256(transaction_bin).digest()).digest()
transaction_hash = transaction_hash_bin.encode("hex")
print(transaction_hash)
3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a

So now that we have the transaction hash for the 1 transaction, we need to find the Merkle root. It turns out that the Merkle root of a single hash is... that single hash. So that is the Merkle root.

Time

29ab5f49, uint32_t. This is 1231006505 in decimal and is a unix timestamp meaning January 3, 2009 at 6:15:05pm UTC.

Bits

ffff001d == 486604799, uint32_t. This is a way to represent the difficulty. It's a sort of floating-point-ish type number. This is difficulty 1 and requires hashes to be below or equal to the target of 0000000000000000000000000000000000000000000000000000FFFF00000000.

Nonce

1dac2b7c == 2083236893, uint32_t

Transaction section

I covered most of this in the merkle root section.

If you want someone else's explanation of each byte of the genesis block, look here.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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