<blockquote>
  <p>I am curious about where the actual hex value of the data that generates that hash with a lot of zeroes is.</p>
</blockquote>

<p>It is a <a href="https://en.bitcoin.it/wiki/Block_hashing_algorithm" rel="nofollow noreferrer">composite of values from the block</a> - in brief, it is the concatenated <strong>binary</strong> (represented here in hex notation) <strong>little endian</strong> value of each of the fields:</p>

<p><strong><code>version + previous_block_hash + merkle_root_hash + time + bits + nonce</code></strong></p>

<p>of the block that is being mined.</p>

<p>These are contained in the "block header".</p>

<p>You have examples of Python code here: <a href="https://en.bitcoin.it/wiki/Block_hashing_algorithm" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Block_hashing_algorithm</a> , for example for <a href="https://blockexplorer.com/block/00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d" rel="nofollow noreferrer">block 125552</a>:</p>

<pre><code>&gt;&gt;&gt; import hashlib
&gt;&gt;&gt; header_hex = ("01000000" +
 "81cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000" +
 "e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122b" +
 "c7f5d74d" +
 "f2b9441a" +
 "42a14695")
&gt;&gt;&gt; header_bin = header_hex.decode('hex')
&gt;&gt;&gt; hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest()
&gt;&gt;&gt; hash.encode('hex_codec')
'1dbd981fe6985776b644b173a4d0385ddc1aa2a829688d1e0000000000000000'
&gt;&gt;&gt; hash[::-1].encode('hex_codec')
'00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d'
</code></pre>

<p>Note that the value is reversed at the last step in order to be represented in the big-endian format that we humans are used to.</p>

<blockquote>
  <p>So, this is what I want: the 80 byte input that gives a 32 bit output with a lot of zeros from sha256(sha256(x)).</p>
</blockquote>

<p>You can check these 6 values for every block mined using any one of the many online block explorers available: for example here for the particular block of the previous example: <a href="https://blockexplorer.com/block/00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d" rel="nofollow noreferrer">https://blockexplorer.com/block/00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d</a> (you'll only have to <a href="https://www.epochconverter.com/" rel="nofollow noreferrer">convert the human time to unix time</a> being careful with the time zone).</p>

<p>Here is a <a href="https://drive.google.com/file/d/1QPDGjz5VXDQsjDZ1TiflEVyY7HOoRIkz/view?usp=sharing" rel="nofollow noreferrer">quick link to download blocks' headers in binary form</a> (until May 2018) and start playing with real values. You <a href="https://bitcoin.stackexchange.com/questions/66873/do-you-know-any-download-site-for-full-blockchain-header-data-6-in-csv-ascii-f/73987#73987">can convert it to .csv</a> if needed.</p>

CC BY-SA 4.0
2019-11-24T17:33:49.180Z
2019-11-24T17:33:49.180Z
circulosmeos
<p>The first 80 bytes of each block are the block header.</p>

<p>You can get the block header for a given block hash by using the <code>getblockheader</code> RPC method.</p>

<p>You can get the block hash for a given block height by using the <code>getblockhash</code> RPC method.</p>

CC BY-SA 4.0
2019-11-24T13:24:39.747Z
2019-11-24T13:24:39.747Z
Raghav Sood
<p>I am trying to research hash functions and I want to be able to use bitcoin's mining outputs as hashes. I am curious about where the actual hex value of the data that generates that hash with a lot of zeroes is. So, this is what I want: the 80 byte input that gives a 32 bit output with a lot of zeros from sha256(sha256(x)).</p>

<hash><block-header>
How to get block header hex?
Sunflower
# How to get block header hex?

(Asked by: username_0 on 2019-11-24)

I am trying to research hash functions and I want to be able to use bitcoin's mining outputs as hashes. I am curious about where the actual hex value of the data that generates that hash with a lot of zeroes is. So, this is what I want: the 80 byte input that gives a 32 bit output with a lot of zeros from sha256(sha256(x)).

**Tags:** hash, block-header


---

## 2 answers

### Answer by username_1 on 2019-11-24. Score: 4

> I am curious about where the actual hex value of the data that generates that hash with a lot of zeroes is.

It is a [composite of values from the block](https://en.bitcoin.it/wiki/Block_hashing_algorithm) - in brief, it is the concatenated **binary** (represented here in hex notation) **little endian** value of each of the fields:

**`version + previous_block_hash + merkle_root_hash + time + bits + nonce`**

of the block that is being mined.

These are contained in the "block header".

You have examples of Python code here: <https://en.bitcoin.it/wiki/Block_hashing_algorithm> , for example for [block 125552](https://blockexplorer.com/block/00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d):

```
>>> import hashlib
>>> header_hex = ("01000000" +
 "81cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000" +
 "e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122b" +
 "c7f5d74d" +
 "f2b9441a" +
 "42a14695")
>>> header_bin = header_hex.decode('hex')
>>> hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest()
>>> hash.encode('hex_codec')
'1dbd981fe6985776b644b173a4d0385ddc1aa2a829688d1e0000000000000000'
>>> hash[::-1].encode('hex_codec')
'00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d'

```

Note that the value is reversed at the last step in order to be represented in the big-endian format that we humans are used to.

> So, this is what I want: the 80 byte input that gives a 32 bit output with a lot of zeros from sha256(sha256(x)).

You can check these 6 values for every block mined using any one of the many online block explorers available: for example here for the particular block of the previous example: <https://blockexplorer.com/block/00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d> (you'll only have to [convert the human time to unix time](https://www.epochconverter.com/) being careful with the time zone).

Here is a [quick link to download blocks' headers in binary form](https://drive.google.com/file/d/1QPDGjz5VXDQsjDZ1TiflEVyY7HOoRIkz/view?usp=sharing) (until May 2018) and start playing with real values. You [can convert it to .csv](https://bitcoin.stackexchange.com/questions/66873/do-you-know-any-download-site-for-full-blockchain-header-data-6-in-csv-ascii-f/73987#73987) if needed.


---

### Answer by username_2 on 2019-11-24. Score: 0

The first 80 bytes of each block are the block header.

You can get the block header for a given block hash by using the `getblockheader` RPC method.

You can get the block hash for a given block height by using the `getblockhash` RPC method.


---

