<p>The Nonce is not difficulty based, the hash of the block is difficulty based. First, the miner hashes the block and checks if the block is solved. If it is not then the Nonce is incremented. If the Nonce overflows (which it does frequently) then the extraNonce portion of the transaction is incremented changing the Merkle Root and the block hash again, so the miner continues and again cycle the Nonce value.</p>

<p>There is some <a href="https://en.bitcoin.it/wiki/Block_hashing_algorithm" rel="nofollow noreferrer">information here</a>.</p>

<p>There is nothing stopping a miner changing locally the difficulty of the block it's mining, but such block simply won't be accepted by the other Bitcoin nodes.</p>

CC BY-SA 3.0
2018-02-16T10:36:54.687Z
2018-02-16T20:56:21.770Z
2018-02-16T20:56:21.770Z
Willtech
<p>Difficulty in Bitcoin is expressed by the hash of a Bitcoin block header being required to be numerically lower than a certain target. This difficulty target is reset every 2016 blocks by up to a factor four up or down. Hereby the difficulty is adjusted that the average hashrate available in the last 2016 blocks would take about 14 days to mine 2016 blocks. E.g. if the 2016 blocks took 10 days instead of 14, difficulty would increase by a factor 1.4.</p>

<p>The nonce is a mean to quickly iterate through many block candidates of the same block template, whereas the extra-nonce is a means to quickly make a slight change to the block template. Every time a new block candidate is hashed, the result is completely unpredictable, so eventually one block candidate will fulfil the difficulty requirement. When this happens, the successful miner broadcasts the new block to the network.</p>

<p>However, every other node in the network will also make sure that the block is actually valid. This includes testing the validity of the block hash from the header, as well as checking every single transaction. Hence, a miner that mines at a lower difficulty might simply broadcast a block that doesn't fulfil the difficulty requirement and thus will be rejected by all other network participants.</p>

CC BY-SA 3.0
2018-02-16T18:05:16.217Z
2018-02-16T18:05:16.217Z
Murch
<p>Good morning,</p>

<p>I'm reading about Blockchain technology but I have a couple of questions about the nonce that I cannot find the answers for.  I'm hoping someone here will be able to answer them.</p>

<p>i)  In order to adjust for the level of computing power available, how is the difficulty of the nonce changed?  What is the mechanism that checks if this should happen and how?</p>

<p>ii) What is to stop a code-savvy miner from changing the difficulty of their generated nonce to something easy so that they are the ones to place the block in the blockchain and win the mined coins?</p>

<p>I'm finding this topic quite fascinating and so any help you guys can provide is always greatly appreciated.</p>

<mining-theory><difficulty><nonce>
How do nonce and difficulty relate?
vasimmahmood
# How do nonce and difficulty relate?

(Asked by: username_0 on 2018-02-16)

Good morning,

I'm reading about Blockchain technology but I have a couple of questions about the nonce that I cannot find the answers for. I'm hoping someone here will be able to answer them.

i) In order to adjust for the level of computing power available, how is the difficulty of the nonce changed? What is the mechanism that checks if this should happen and how?

ii) What is to stop a code-savvy miner from changing the difficulty of their generated nonce to something easy so that they are the ones to place the block in the blockchain and win the mined coins?

I'm finding this topic quite fascinating and so any help you guys can provide is always greatly appreciated.

**Tags:** mining-theory, difficulty, nonce


---

## 2 answers

### Answer by username_1 on 2018-02-16. Score: 2

The Nonce is not difficulty based, the hash of the block is difficulty based. First, the miner hashes the block and checks if the block is solved. If it is not then the Nonce is incremented. If the Nonce overflows (which it does frequently) then the extraNonce portion of the transaction is incremented changing the Merkle Root and the block hash again, so the miner continues and again cycle the Nonce value.

There is some [information here](https://en.bitcoin.it/wiki/Block_hashing_algorithm).

There is nothing stopping a miner changing locally the difficulty of the block it's mining, but such block simply won't be accepted by the other Bitcoin nodes.


---

### Answer by username_2 on 2018-02-16. Score: 2

Difficulty in Bitcoin is expressed by the hash of a Bitcoin block header being required to be numerically lower than a certain target. This difficulty target is reset every 2016 blocks by up to a factor four up or down. Hereby the difficulty is adjusted that the average hashrate available in the last 2016 blocks would take about 14 days to mine 2016 blocks. E.g. if the 2016 blocks took 10 days instead of 14, difficulty would increase by a factor 1.4.

The nonce is a mean to quickly iterate through many block candidates of the same block template, whereas the extra-nonce is a means to quickly make a slight change to the block template. Every time a new block candidate is hashed, the result is completely unpredictable, so eventually one block candidate will fulfil the difficulty requirement. When this happens, the successful miner broadcasts the new block to the network.

However, every other node in the network will also make sure that the block is actually valid. This includes testing the validity of the block hash from the header, as well as checking every single transaction. Hence, a miner that mines at a lower difficulty might simply broadcast a block that doesn't fulfil the difficulty requirement and thus will be rejected by all other network participants.


---

