<p>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.</p>

<h2>The Merkle Root</h2>

<p>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 <a href="https://en.bitcoin.it/wiki/Protocol_specification#tx" rel="nofollow">this</a> format.</p>

<pre><code>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
</code></pre>

<p>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.</p>

<h2>Time</h2>

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

<h2>Bits</h2>

<p>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.</p>

<h2>Nonce</h2>

<p>1dac2b7c == 2083236893, uint32_t</p>

<h2>Transaction section</h2>

<p>I covered most of this in the merkle root section. </p>

<p>If you want someone else's explanation of each byte of the genesis block, <a href="https://en.bitcoin.it/wiki/Genesis_block" rel="nofollow">look here</a>.</p>

CC BY-SA 3.0
2014-07-05T07:06:15.857Z
2014-07-05T07:06:15.857Z
Buge
<p>The question asked <a href="https://bitcoin.stackexchange.com/q/9732">here</a> 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):</p>

<ol>
<li>The Merkle Root</li>
<li>Time</li>
<li>Bits</li>
<li>Nonce</li>
<li>The Transaction Section:

<ul>
<li>Coinbase</li>
<li>scriptSig</li>
<li>scriptPubKey</li>
</ul></li>
</ol>

<p>It is still unclear to me where all these elements come from. </p>

<p>The Merkle Root, as I understand it, is basically a hash of many hashes (Good example <a href="https://en.bitcoin.it/wiki/Protocol_specification#Merkle_Trees" rel="nofollow noreferrer">here</a>) - 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" <a href="https://en.bitcoin.it/wiki/Protocol_specification#tx" rel="nofollow noreferrer">here</a>.</p>

<p>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 <a href="https://bitcoin.stackexchange.com/questions/2025/what-is-txins-sequence">similar question</a> but it was never answered really (unless TxIn sequence is something totally different from just TxIn).</p>

<p>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.</p>

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

CC BY-SA 3.0
2014-05-01T08:36:42.337Z
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](http://bitcoindev.us.to/en/developer-guide#block-header) with the Time, Bits, Nonce etc and more on the the [Merkleroot](http://bitcoindev.us.to/en/developer-guide#term-merkle-root)
Ruben de Vries
<transactions><blockchain><raw-data><genesis-block><coinbase-transaction>
Details on Genesis Block
HenryDorsettCase
# Details on Genesis Block

(Asked by: username_0 on 2013-12-10)

The question asked [here](https://bitcoin.stackexchange.com/q/9732) 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](https://en.bitcoin.it/wiki/Protocol_specification#Merkle_Trees)) - 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](https://en.bitcoin.it/wiki/Protocol_specification#tx).

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](https://bitcoin.stackexchange.com/questions/2025/what-is-txins-sequence) 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?

**Tags:** transactions, blockchain, raw-data, genesis-block, coinbase-transaction

> **Comments:**
> **username_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](http://bitcoindev.us.to/en/developer-guide#block-header) with the Time, Bits, Nonce etc and more on the the [Merkleroot](http://bitcoindev.us.to/en/developer-guide#term-merkle-root)  

---

## 1 answers

### Answer by username_2 on 2014-07-05. Score: 1

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](https://en.bitcoin.it/wiki/Protocol_specification#tx) 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](https://en.bitcoin.it/wiki/Genesis_block).


---

