First, you need to convert your decimal number into hex.
Then you will have a packed represantation of the target.
Thanks for the quick reply. A problem I have is how to interpret the number returned, for example
4306949573981.513
What does the period represent? Is it simply a decimal point? If so, do I ignore the digits to the right of the decimal point when converting the number to hex?
Does the period represent a floating point number?
I have to correct my statement, please ignore those two sentences.
getDifficulty() returns the factor (decimal) which describes how much more difficult it is to find a block, relative to the difficulty at the highest possible target (highest target = lowest difficulty).
Difficulty = largest possible target / current target.
So to calculate the target you have to divide the largest possible target (
0x00000000FFFF0000000000000000000000000000000000000000000000000000) by the difficulty.
In your case:
Largest possible target:
(
0x00000000FFFF0000000000000000000000000000000000000000000000000000)
16 = (
26959535291011309493156476344723991336010898738574164086137773096960)
10Largest target / difficulty:
26959535291011309493156476344723991336010898738574164086137773096960) /
4306949573981.513 =
6.2595428 * 1054Converted into hex:
0x415A48FC207EB1A005D72938CFF3FCCF0A000000000000Now padding with leading 0's until length = 64: 0x
000000000000000000415A48FC207EB1A005D72938CFF3FCCF0A000000000000So the current target is :
000000000000000000415A48FC207EB1A005D72938CFF3FCCF0A000000000000The hash of the
latest block is
0000000000000000003424388ace9f93daaaf2980e41fcf0408e0c6f10800de9