<p>I'm afraid I don't know Java, but the target is worked out as follows:</p>

<pre><code>target = maximum target / difficulty
</code></pre>

<hr>

<blockquote>
  <p>Note: The <strong>maximum target</strong> is <code>0x00000000FFFF0000000000000000000000000000000000000000000000000000</code> (which in decimal is <code>26959535291011309493156476344723991336010898738574164086137773096960</code>)</p>
</blockquote>

<p>Therefore:</p>

<pre><code>target = maximum target / difficulty
target = 26959535291011309493156476344723991336010898738574164086137773096960 / 1
target = 26959535291011309493156476344723991336010898738574164086137773096960
</code></pre>

<p>So if you convert that back to hex you get:</p>

<pre><code>0xFFFF0000000000000000000000000000000000000000000000000000
</code></pre>

<p>Then you can just pad zeros on the left to make it 64 characters:</p>

<pre><code>0x00000000FFFF0000000000000000000000000000000000000000000000000000
</code></pre>

<hr>

<p><a href="http://learnmeabitcoin.com/manual/guide/difficulty#finding-the-target-using-the-difficulty" rel="nofollow">http://learnmeabitcoin.com/manual/guide/difficulty#finding-the-target-using-the-difficulty</a></p>

CC BY-SA 3.0
2016-10-25T11:42:41.650Z
Thank you for your information. I read more about the Stratum protocol and I found that the current network difficulty is stored in the nBits variable.
Nikos
CC BY-SA 3.0
2016-10-25T11:43:44.240Z
So now I have to figure out how I can convert the nBits to Target.
Nikos
CC BY-SA 3.0
2016-10-20T18:15:46.303Z
2016-10-20T18:15:46.303Z
inersha
<p>Reading the slushpool's manual for the Stratum protocol I found that :</p>

<p><em>"Default share difficulty is 1 (big-endian target for difficulty 1 is <strong>0x00000000ffff0000000000000000000000000000000000000000000000000000</strong>)"</em></p>

<p>Anyone knows how to generate this 64characters long big-endian representation of the number 1 ? I would appreciate any code in Java.</p>

<p>Thank you </p>

<difficulty><java>
How to generate bitcoin target from difficulty?
Nikos
# How to generate bitcoin target from difficulty?

(Asked by: username_0 on 2016-10-19)

Reading the slushpool's manual for the Stratum protocol I found that :

*"Default share difficulty is 1 (big-endian target for difficulty 1 is **0x00000000ffff0000000000000000000000000000000000000000000000000000**)"*

Anyone knows how to generate this 64characters long big-endian representation of the number 1 ? I would appreciate any code in Java.

Thank you

**Tags:** difficulty, java


---

## 1 answers

### Answer by username_1 on 2016-10-20. Score: 1

I'm afraid I don't know Java, but the target is worked out as follows:

```
target = maximum target / difficulty

```

---

> Note: The **maximum target** is `0x00000000FFFF0000000000000000000000000000000000000000000000000000` (which in decimal is `26959535291011309493156476344723991336010898738574164086137773096960`)

Therefore:

```
target = maximum target / difficulty
target = 26959535291011309493156476344723991336010898738574164086137773096960 / 1
target = 26959535291011309493156476344723991336010898738574164086137773096960

```

So if you convert that back to hex you get:

```
0xFFFF0000000000000000000000000000000000000000000000000000

```

Then you can just pad zeros on the left to make it 64 characters:

```
0x00000000FFFF0000000000000000000000000000000000000000000000000000

```

---

<http://learnmeabitcoin.com/manual/guide/difficulty#finding-the-target-using-the-difficulty>

> **Comments:**
> **username_0**: Thank you for your information. I read more about the Stratum protocol and I found that the current network difficulty is stored in the nBits variable.  
> **username_0**: So now I have to figure out how I can convert the nBits to Target.  

---

