<p>There are two values in play here, and the way your question is phrased makes me think you're confusing them.</p>
<p>Every block has:</p>
<ul>
<li>A hash (computed by double-SHA256 the block header, including timestamp, nonce, version, Merkle root, nBits which encodes the difficulty, and previous block hash)</li>
<li>A target (computed from the difficulty only)</li>
</ul>
<p><code>000000000000000000084bc771b929b0780276b1c31cec10a96921b1e53b970a</code> is the <em>hash</em> of block number 669945. Just feeding the block's header exactly to double-SHA256 gives you this output (including the zeroes up front). It gets interpreted as a number:</p>
<ul>
<li>0x000000000000000000084bc771b929b0780276b1c31cec10a96921b1e53b970a (in hex, with zeroes explicit)</li>
<li>0x84bc771b929b0780276b1c31cec10a96921b1e53b970a (in hex)</li>
<li>794600089940753232651370066465976921098309156434843402 (converted to decimal)</li>
</ul>
<p>The target is the maximum allowed value that hash must have to satisfy the proof-of-work requirement. It is determined entirely by the difficulty(*) (which on its turn is determined by the timestamps of the previous blocks in the chain it is built on). That difficulty is also stored in the block header itself as the &quot;nBits&quot; value. The nBits value for block 669945 is 0x170d21b9; it encodes <em>0x0d21b9 · 256<sup>0x17 - 3</sup></em>, which equals:</p>
<ul>
<li>0x0d21b900000000000000000000000000000000 (in hex)</li>
<li>1257769770588612382309009370720465882998915202417688576 (converted to decimal)</li>
</ul>
<p>Since 794600089940753232651370066465976921098309156434843402 (the actual hash's value) is less than 1257769770588612382309009370720465882998915202417688576 (the target value), proof-of-work is valid for this block. And of course it is; if it wasn't, you would never have heard about this (attempted) block candidate.</p>
<p>(*) Technically speaking, the term &quot;difficulty&quot; is only used for representing how hard a block is for human consumption. Internally only nBits and the full target value are ever used. Difficulty is defined as <em>0xffff·256<sup>26</sup> / target</em>. The lower the target, the harder it is to find a block whose hash is below it, and thus the higher the difficulty is.</p>

CC BY-SA 4.0
2021-02-10T05:09:46.847Z
1 question, what do you mean by `encodes 0x0d21b9 · 256^0x17 - 3`? I understood everything else and it was very helpful, but just confused about that part. Not sure where you go the 0x0d21b9 and 256^0x17 - 3 from.
L M 
CC BY-SA 4.0
2021-02-10T05:17:45.467Z
That's just how nBits works. If nBits = 0xABCDEFGH, that encodes the target value 0xCDEFGH * 256^(0xAB - 3). I don't know where or how Satoshi came up with it, but that's the definition.
Pieter Wuille
CC BY-SA 4.0
2021-02-10T04:30:10.660Z
2021-02-10T05:48:07.060Z
2021-02-10T05:48:07.060Z
Pieter Wuille
<p>I think you're confusing a few things.</p>
<p>A SHA-256 hash is a single value that is 64 hexadecimal characters long. This hash can be seen as simply a very long number.</p>
<p>A target hash in cryptocurrencies is the maximum value that a successful block hash should be. Miners are aiming to generate a block where the hash, when seen as a large number, is a smaller number than the target hash.</p>
<p>The entire thing <code>000000000000000000084bc771b929b0780276b1c31cec10a96921b1e53b970a</code> is a block hash. It is a SHA256 hash, and just happens to be a number that contains a lot of zeroes.</p>
<p>If you want to see how the block hash is calculated, take a look at this article: <a href="https://en.bitcoin.it/wiki/Block_hashing_algorithm" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Block_hashing_algorithm</a></p>

CC BY-SA 4.0
2021-02-10T04:29:47.363Z
2021-02-10T04:29:47.363Z
ieatpizza
<p>So, I understand how the amount of leading 0's are calculated, but how is the hexadecimal that come after the leading 0's calculated? For example, the previous mined blocks hash was
<code>000000000000000000084bc771b929b0780276b1c31cec10a96921b1e53b970a</code> but how was the <code>84bc771b929b0780276b1c31cec10a96921b1e53b970a</code> after the 0's determined?</p>
<p>I saw this answer: <a href="https://bitcoin.stackexchange.com/a/36228/110284">https://bitcoin.stackexchange.com/a/36228/110284</a> but I'm not gonna lie, I didn't understand it.</p>

CC BY-SA 4.0
2021-02-10T04:15:13.020Z
@PieterWuille Unfortunately not because I was under the impression that 3 of the variables (Time, Nonce, and Merkle Root) change or are not present before the block is completed. I thought the Time continues ticking until the block is successfully mined, the Nonce constantly iterates until the correct nonce is found, and the Merkle Root is the hash of all the transactions that occur in that block. So how can the Target Hash for a block be created from those values if the values constantly change prior to the blocks completion?
L M 
CC BY-SA 4.0
2021-02-10T04:38:57.403Z
@L M I think I see your confusion. I retracted my close vote, and wrote an answer.
Pieter Wuille
<blockchain><block><hash><nonce>
How is the Target Hash determined?
L M 
# How is the Target Hash determined?

(Asked by: username_0 on 2021-02-10)

So, I understand how the amount of leading 0's are calculated, but how is the hexadecimal that come after the leading 0's calculated? For example, the previous mined blocks hash was
`000000000000000000084bc771b929b0780276b1c31cec10a96921b1e53b970a` but how was the `84bc771b929b0780276b1c31cec10a96921b1e53b970a` after the 0's determined?

I saw this answer: <https://bitcoin.stackexchange.com/a/36228/110284> but I'm not gonna lie, I didn't understand it.

**Tags:** blockchain, block, hash, nonce

> **Comments:**
> **username_0**: @username_1 Unfortunately not because I was under the impression that 3 of the variables (Time, Nonce, and Merkle Root) change or are not present before the block is completed. I thought the Time continues ticking until the block is successfully mined, the Nonce constantly iterates until the correct nonce is found, and the Merkle Root is the hash of all the transactions that occur in that block. So how can the Target Hash for a block be created from those values if the values constantly change prior to the blocks completion?  
> **username_1**: @username_0I think I see your confusion. I retracted my close vote, and wrote an answer.  

---

## 2 answers

### Answer by username_1 on 2021-02-10. Score: 3 | Accepted answer

There are two values in play here, and the way your question is phrased makes me think you're confusing them.

Every block has:

* A hash (computed by double-SHA256 the block header, including timestamp, nonce, version, Merkle root, nBits which encodes the difficulty, and previous block hash)
* A target (computed from the difficulty only)

`000000000000000000084bc771b929b0780276b1c31cec10a96921b1e53b970a` is the *hash* of block number 669945. Just feeding the block's header exactly to double-SHA256 gives you this output (including the zeroes up front). It gets interpreted as a number:

* 0x000000000000000000084bc771b929b0780276b1c31cec10a96921b1e53b970a (in hex, with zeroes explicit)
* 0x84bc771b929b0780276b1c31cec10a96921b1e53b970a (in hex)
* 794600089940753232651370066465976921098309156434843402 (converted to decimal)

The target is the maximum allowed value that hash must have to satisfy the proof-of-work requirement. It is determined entirely by the difficulty(\*) (which on its turn is determined by the timestamps of the previous blocks in the chain it is built on). That difficulty is also stored in the block header itself as the "nBits" value. The nBits value for block 669945 is 0x170d21b9; it encodes *0x0d21b9 · 2560x17 - 3*, which equals:

* 0x0d21b900000000000000000000000000000000 (in hex)
* 1257769770588612382309009370720465882998915202417688576 (converted to decimal)

Since 794600089940753232651370066465976921098309156434843402 (the actual hash's value) is less than 1257769770588612382309009370720465882998915202417688576 (the target value), proof-of-work is valid for this block. And of course it is; if it wasn't, you would never have heard about this (attempted) block candidate.

(\*) Technically speaking, the term "difficulty" is only used for representing how hard a block is for human consumption. Internally only nBits and the full target value are ever used. Difficulty is defined as *0xffff·25626 / target*. The lower the target, the harder it is to find a block whose hash is below it, and thus the higher the difficulty is.

> **Comments:**
> **username_0**: 1 question, what do you mean by `encodes 0x0d21b9 · 256^0x17 - 3`? I understood everything else and it was very helpful, but just confused about that part. Not sure where you go the 0x0d21b9 and 256^0x17 - 3 from.  
> **username_1**: That's just how nBits works. If nBits = 0xABCDEFGH, that encodes the target value 0xCDEFGH * 256^(0xAB - 3). I don't know where or how Satoshi came up with it, but that's the definition.  

---

### Answer by username_2 on 2021-02-10. Score: 2

I think you're confusing a few things.

A SHA-256 hash is a single value that is 64 hexadecimal characters long. This hash can be seen as simply a very long number.

A target hash in cryptocurrencies is the maximum value that a successful block hash should be. Miners are aiming to generate a block where the hash, when seen as a large number, is a smaller number than the target hash.

The entire thing `000000000000000000084bc771b929b0780276b1c31cec10a96921b1e53b970a` is a block hash. It is a SHA256 hash, and just happens to be a number that contains a lot of zeroes.

If you want to see how the block hash is calculated, take a look at this article: <https://en.bitcoin.it/wiki/Block_hashing_algorithm>


---

