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?

1 Answer 1


A useful link on the subject.

  1. Target is computed from a value called "Bits". 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. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.