<p>Have you read this? It is sort of technical, and goes into <code>How is difficulty calculated?</code> and <code>How is difficulty stored in blocks?</code></p>
<p><a href="https://en.bitcoin.it/wiki/Difficulty" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Difficulty</a></p>
<p>re your comment about nonces: The nonce is not the difficulty. In the example below, I'm trying to find a sha256 that starts with 0. On my imaginary blockchain, a proof-of-work that starts with a single 0 is good enough. Notice that I don't change anything but the number after <code>foo</code>. The number after foo can be thought of as the nonce. It's just some thing I change to get a new proof-of-work.</p>
<pre><code>[I] ➜  ~ echo -n &quot;foo&quot; | shasum -a 256
2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae  -
[I] ➜  ~ echo -n &quot;foo1&quot; | shasum -a 256
bb4eca334f61af3b67b5d528907d30285151610200539302f4c8cabe66225b53  -
[I] ➜  ~ echo -n &quot;foo2&quot; | shasum -a 256
4963bd713a7eb1bce458868b0c8472bdc8bc5929a7892a92dd24344aea92093d  -
[I] ➜  ~ echo -n &quot;foo19&quot; | shasum -a 256
06651ba147df6422edcd47690fd3d68795bc59636f37f10b67a94fa70fe1fdbb  - yay
</code></pre>
<p>Compare that with miners on the bitcoin blockchain. Currently they have to find a sha256 hash that starts with 19 0's. e.g: <code>00000000000000000006d31a10b4190a8f86c93189debe87a4d1fff54fbd5b23</code></p>

CC BY-SA 4.0
2021-02-01T23:04:12.467Z
Yeah, I did read that but unfortuantely, it was a bit too technical for my current understanding. I don't quite understand what the difficulty target changes. From my understanding, the nonce is what people need to find in order to complete the block. But currently the bitcoin blockchain has a difficulty of 20,823,531,150,111.52. That's 20 trillion, yet the nonce from what I can see currently varies between the hundreds of millions and 5 billion ish. 

Basically I don't understand how (or whether it even does) it affects the nonce and the persons ability to complete the block.
L M 
CC BY-SA 4.0
2021-02-02T07:38:40.313Z
The nonce isn't the only thing that varies between attempts. In fact, difficulty 1 means that only one in ~4 billion attempts will succeed. The current difficulty means you need trillions of times that many attempts (yes, really). In order to do so, miners change other things in the block to get more chances - the timestamp, an additional nonce inside the block data itself, the composition of transactions, ...
Pieter Wuille
CC BY-SA 4.0
2021-02-01T22:08:07.320Z
2021-02-02T07:24:11.130Z
2021-02-02T07:24:11.130Z
Bjørn Olav Jalborg
<p>So, I'm currently doing a personal project where I'm creating my own crypto blockchain (just for fun). I'm currently coding the Difficulty Target part of the Blockchain, but I'm not entirely sure how the difficulty part affects the process for completing the block? I know that with Bitcoin, the difficulty adjusts every 2016 blocks based on how long it took to complete the 2016 blocks, but what is the difficulty applied to and how does it make subsequent blocks harder/easier to complete?</p>
<p>Thanks.</p>

<blockchain><block><difficulty>
How does the difficulty target affect the time to complete the block?
L M 
# How does the difficulty target affect the time to complete the block?

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

So, I'm currently doing a personal project where I'm creating my own crypto blockchain (just for fun). I'm currently coding the Difficulty Target part of the Blockchain, but I'm not entirely sure how the difficulty part affects the process for completing the block? I know that with Bitcoin, the difficulty adjusts every 2016 blocks based on how long it took to complete the 2016 blocks, but what is the difficulty applied to and how does it make subsequent blocks harder/easier to complete?

Thanks.

**Tags:** blockchain, block, difficulty


---

## 1 answers

### Answer by username_1 on 2021-02-01. Score: 0

Have you read this? It is sort of technical, and goes into `How is difficulty calculated?` and `How is difficulty stored in blocks?`

<https://en.bitcoin.it/wiki/Difficulty>

re your comment about nonces: The nonce is not the difficulty. In the example below, I'm trying to find a sha256 that starts with 0. On my imaginary blockchain, a proof-of-work that starts with a single 0 is good enough. Notice that I don't change anything but the number after `foo`. The number after foo can be thought of as the nonce. It's just some thing I change to get a new proof-of-work.

```
[I] ➜  ~ echo -n "foo" | shasum -a 256
2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae  -
[I] ➜  ~ echo -n "foo1" | shasum -a 256
bb4eca334f61af3b67b5d528907d30285151610200539302f4c8cabe66225b53  -
[I] ➜  ~ echo -n "foo2" | shasum -a 256
4963bd713a7eb1bce458868b0c8472bdc8bc5929a7892a92dd24344aea92093d  -
[I] ➜  ~ echo -n "foo19" | shasum -a 256
06651ba147df6422edcd47690fd3d68795bc59636f37f10b67a94fa70fe1fdbb  - yay

```

Compare that with miners on the bitcoin blockchain. Currently they have to find a sha256 hash that starts with 19 0's. e.g: `00000000000000000006d31a10b4190a8f86c93189debe87a4d1fff54fbd5b23`

> **Comments:**
> **username_0**: Yeah, I did read that but unfortuantely, it was a bit too technical for my current understanding. I don't quite understand what the difficulty target changes. From my understanding, the nonce is what people need to find in order to complete the block. But currently the bitcoin blockchain has a difficulty of 20,823,531,150,111.52. That's 20 trillion, yet the nonce from what I can see currently varies between the hundreds of millions and 5 billion ish.   Basically I don't understand how (or whether it even does) it affects the nonce and the persons ability to complete the block.  
> **username_2**: The nonce isn't the only thing that varies between attempts. In fact, difficulty 1 means that only one in ~4 billion attempts will succeed. The current difficulty means you need trillions of times that many attempts (yes, really). In order to do so, miners change other things in the block to get more chances - the timestamp, an additional nonce inside the block data itself, the composition of transactions, ...  

---

