pub package Null Safety CI GitHub Tag New Commits Last Commits Pull Requests Code size License

Dart wrapper for RandomX proof-of-work (PoW) algorithm.


A simple usage example:

import 'dart:typed_data';
import 'package:dart_randomx/dart_randomx.dart';

Future<void> main() async {
  await RandomX.loadLib();

  var randomX = RandomX();


  var key = Uint8List.fromList([97, 98, 99, 100, 101, 102, 0]);

  var data = Uint8List.fromList([65, 66, 67, 68, 69, 0]);

  var hash = randomX.hash(data);


RandomX Full Memory

The RandomX algorithm has 2 modes:

  • slow: uses less memory but is slower.
  • fast: faster (about 10x) but uses 2G+ of memory.

To activate the fast mode just initialize it passing fullMemory as true:

Future<void> main() async {
  await RandomX.loadLib();
  var randomX = RandomX();
  randomX.init(key, fullMemory: true);

Library Binaries

This package already comes with built-in binaries for the RandomX wrapper library. They are located at the sub-directory wrapper_randomx_library/:

  • libwrapper_randomx.dll (Windows x64)
  • libwrapper_randomx.so (Linux x64)
  • libwrapper_randomx-x64.dylib (macOS x64)
  • libwrapper_randomx-arm64.dylib (macOS ARM64)

Project Build

See the script build-ffi-lib.sh to build the libraries:

  • randomx: the RandomX PoW algorithm.
  • wrapper_randomx: dart:ffi wrapper of lib randomx.

The directory wrapper_randomx_library has the source code for the dart:ffi wrapper and the build scripts:

  • build-librandomx.sh:

    Will clone the RandomX project, build it and place the library file librandomx.a at wrapper_randomx_library/ to then build the wrapper.

  • build-wrapper.sh:

    Builds the wrapper, linking with librandomx.a.

For Windows support see the file wrapper_randomx_library/build-all-mingw64.sh. You will need to install MSYS2 and some packages:

pacman -S --needed development
pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc
pacman -S --needed ninja

NOTE: The build process was tested on macOS 11, Linux (Ubuntu 18) and Windows 10.

RandomX Project

The RandomX proof-of-work (PoW) algorithm can be found at:

NOTE: The script build-librandomx.sh automatically clones and builds it.

RandomX Configuration

The RandomX project recommends a different configuration for each coin, defined by the file RandomX/src/configuration.h. See the configuration documentation:

The default configuration for this project is the same of Monero:

  • wrapper_randomx_library/configuration-monero.h

NOTE: RandomX was originally developed for Monero.*


Graciliano M. Passos: gmpassos@GitHub.


BSD-3-Clause License


Dart wrapper for RandomX proof-of-work (PoW) algorithm.