How does monero calculate the achieved difficulty of a mined block given a pow hash from randomx. I dont know if this is perhaps the correct place to ask this. If its not is there a better place to pin this? I looked here: How can I tell what difficulty my solution is?

From that I copied the code to a nodejs scratchpad: https://repl.it/repls/KaleidoscopicLiquidVideogames:


Buffer.prototype.toByteArray = function () {
    return Array.prototype.slice.call(this, 0);

let hex_hash = "9ac67c5a2793861093ffa3f3fbeeffd8e9971fe555f59a0735c2d50500000000";
var hash = new Buffer.from(hex_hash,'hex');
var hashArray = hash.toByteArray().reverse();
var hashNum = bignum.fromBuffer(Buffer.from(hashArray));
var hashDiff = baseDiff.div(hashNum);

I also wrote code in rust, the values match from the rust vs nodejs. But they do not match the difficulty from the block explorers. The code above results in difficulty achieved: 188434043243 While the block explorer: https://xmrchain.net/block/2196393 results in 159730146809.

Dotting the differences again here for easy viewing:



Why is there a difference there?

1 Answer 1


Why is there a difference there?

The difficulty displayed on block explorers is the difficulty the hash has to be greater than, not what difficulty the hash is.

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.