<p><a href="https://bitcointalk.org/index.php?topic=51281.msg611856#msg611856" rel="nofollow noreferrer">A useful link on the subject.</a></p>

<ol>
<li><p><a href="https://en.bitcoin.it/wiki/Difficulty" rel="nofollow noreferrer">Target is computed from a value called "Bits".</a> A Bits value of 0x1b0404cb is equivalent to Target of 0x0404cb * 2^(8*(0x1b - 3)) = 0x00000000000404CB000000000000000000000000000000000000000000000000 . A Pool usually specifies the Target to be just shy of Difficulty 1 Target (a typical Target for a Share), which is equal to 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF .</p></li>
<li><p><a href="https://stackoverflow.com/a/9322486/953732">Calculating a midstate is a big pain</a>. Basically, you need to get an internal state of the SHA-256 function that will be used in calculating the block hash. Also, you have to be mindful that Bitcoin's endianness is all over the board and you have to be swapping bytes around for no apparent reason every now and then.</p></li>
<li><p>Data is just a padded block header.</p></li>
</ol>

<p>Hopefully with this general explanation and links to examples of the calculations you will be able to compute all the required data as needed.</p>

CC BY-SA 3.0
2013-06-05T09:57:18.143Z
2013-06-05T09:57:18.143Z
2017-05-23T12:34:59.703Z
ThePiachu
<p>I am playing around with a bitcoin miner and wanted to run some tests. Hence I wanted to find the nonce of an already mined block. Lets take  <a href="http://blockchain.info/block-index/353394/0000000000000083ee9371ddff055eed7f02348e4eda36c741a2fc62c85bc5cf" rel="nofollow">http://blockchain.info/block-index/353394/0000000000000083ee9371ddff055eed7f02348e4eda36c741a2fc62c85bc5cf</a> as an example. I can find the nonce. I can calculate the block header. But how do I find out what the target was as well as what the <code>midstate and data</code> was when the <code>getwork</code> was called for that particular block at the time of mining?</p>

<api><mining-technical-details>
Find the midstate of an already mined block
Enthusiast
# Find the midstate of an already mined block

(Asked by: username_0 on 2013-06-03)

I am playing around with a bitcoin miner and wanted to run some tests. Hence I wanted to find the nonce of an already mined block. Lets take <http://blockchain.info/block-index/353394/0000000000000083ee9371ddff055eed7f02348e4eda36c741a2fc62c85bc5cf> as an example. I can find the nonce. I can calculate the block header. But how do I find out what the target was as well as what the `midstate and data` was when the `getwork` was called for that particular block at the time of mining?

**Tags:** api, mining-technical-details


---

## 1 answers

### Answer by username_1 on 2013-06-05. Score: 3

[A useful link on the subject.](https://bitcointalk.org/index.php?topic=51281.msg611856#msg611856)

1. [Target is computed from a value called "Bits".](https://en.bitcoin.it/wiki/Difficulty) A Bits value of 0x1b0404cb is equivalent to Target of 0x0404cb \* 2^(8\*(0x1b - 3)) = 0x00000000000404CB000000000000000000000000000000000000000000000000 . A Pool usually specifies the Target to be just shy of Difficulty 1 Target (a typical Target for a Share), which is equal to 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF .
2. [Calculating a midstate is a big pain](https://stackoverflow.com/a/9322486/953732). Basically, you need to get an internal state of the SHA-256 function that will be used in calculating the block hash. Also, you have to be mindful that Bitcoin's endianness is all over the board and you have to be swapping bytes around for no apparent reason every now and then.
3. Data is just a padded block header.

Hopefully with this general explanation and links to examples of the calculations you will be able to compute all the required data as needed.


---

