Monero(XMR) RandomX PoW Algorithm Explained

This article briefly introduces the unique properties of the algorithm used by Monero called RandomX.

Monero(XMR) RandomX PoW Algorithm Explained

Among proof of work algorithms(PoW), randomx is an algorithm tailored specifically for the privacy-oriented cryptocurrency Monero(XMR) and is well-known for several unique properties.

RandomX properties at a glance

  • CPU-oriented, giving GPU/FPGA-mining a significant disadvantage.
  • Dynamic work, implementing a nearly ASIC-proof property.
  • Memory threshold, makes botnet/malware mining easily detectable and in some cases unable to undergo mining

How it Works(Simple Version)

Easily speaking, the algorithm executes a dynamic series of functions with two different pieces of data as input on a VM then hashes the result. If the result matches fits the current criteria, the block is committed to the ledger with the miner rewarded the block reward.

How it Works(Detailed Version)

  1. The algorithm takes the hash of a key block (input k), and transaction data with a nonce value (input h) as input. The key block is the last block prior to the current block that is divisible by 2048.
  2. A VM is then initialized. The workspace memory of the VM (aka scratchpad) is generated with input h.
  3. A read-only dataset is then generated with input k. The VM programming instructions are derived from data from this dataset via a generator (g4) seeded by the result of one of the scratchpad generators.
  4. The VM is executed.
  5. The state of generator g4 is set to the hash of the VM registry.
  6. Repeats from step 3 a specified amount of times.
  7. A result (R) derived from the hash of the scratchpad and VM registry is returned.
  8. If result R fits the target difficulty of the block, the block is committed with the miner reward given to the miner.

More about properties

The instruction sets that are run on the VM are based on CPU instructions. Since native instructions are different for the varying kinds of hardware, this poses the first barrier for non-CPU chips. GPUs lack the ability to perform specific kinds of calculations, which miners will have to figure go-arounds for, closed-source GPU drivers pose a barrier as well. RandomX utilizes these traits to properly form a threshold for GPU miners. As for FPGA(Field Programmable Gate Array), there are 2⁵¹² possible unique programs, which poses as a barrier impossible for FPGAs, which utilizes bitstream loading, to sustain acceptable efficiency.

RandomX implements dynamic work, random unique programs are generated by data selected from the Dataset generated from the hash of a key block. The specified programs follow a pre-programmed sequence that cannot be altered without affecting the result. Programs latter in the sequence uses the state of the machine after the previous calculation, thus preventing so-called “easy problem” attack.

The algorithm is also memory-intensive(2GB-plus RAM), letting mining malware to be easily detectable by system administrators or antivirus software. Low-end IoT devices, which are often less secure, will not be able to run the algorithm because of the lack of RAM. Web applications will also not be able to do covert mining due to the limit on most sandboxed environments in modern browsers.

ASIC miners have become a problem in the current few years, with specifically designed circuits/chips, the custom miners pose a threat by being able to launch 51% attacks and extremely high target difficulties. RansomX algorithm is designed with the following properties of ASIC miners:

  • RAM memory is expensive for ASIC miners
  • ASIC chips are designed to run specific programs instead of dynamic ones.

With the high memory requirements and dynamic unique programs, ASIC miners are effectively blocked from mining on the network.


RandomX can be seen as a permanently solution(might be broken, but should not be in the near future) to the common problems that PoW algorithms may face. For more information/source code of the project, see the repo on GitHub tevador/RandomX.