1

From my understanding, you simply need to use a SHA256 function to hash the block's header (Block hash and merkle root) then add the nonce at the end like this article explains.

However, I can't manage to get the correct next block hash. By using the block #505400 :

Hash : 00000000000000000023b89dd18f6be5a6c03a71cd864ccbdf024683114b9ce3

Merkle root : a3defcaa713d267eacab786c4cc9c0df895d8ac02066df6c84c7aec437ae17ae

Nonce : 2816816696

Next block hash : 0000000000000000007625ff74171cf53e301c3e5013bf2184e2629a2da0fc8d

What I am expecting : sha256(Hash + Merkle Root + Nonce) = Next Block Hash

However I get this : 10345cb85ffed406a47e1faf31eb8ba1160aac0fbaae3cae0cd66889f9c9f49e

What did I do wrong?

2

That isn't the way a block header is created. The block header is constructed as the version, the hash of the previous block, the merkle root, the timestamp, the nBits field and the nonce. Once serialized in bytes, the header is hashed twice with SHA256 not just once. A common mistake is to hash the string of hex representation of the bytes, you must hash the bytes themselves.

See here for more info: https://en.bitcoin.it/wiki/Block_hashing_algorithm

The hash is the hash of that block. It does not give the hash of the next block following it, there is no way to know what the next block hash will be and there are many possible hashes it could be

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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