opt-in-miner 0.4.1

Opt-in Monero/Wownero mining library for transparent application monetization
Documentation

Opt-in Miner

A Rust library that embeds opt-in cryptocurrency mining into applications as a monetization model. Supports both Monero (RandomX) and Wownero (RandomWOW).

What this is

An alternative to ads, subscriptions, or paywalls. Applications using this library mine Monero (XMR) or Wownero (WOW) in the background using spare CPU capacity. The key word is opt-in: the library provides a consent mechanism and it is recommended that users explicitly consent before any mining occurs.

What this is not

This is not cryptojacking. Cryptojacking is mining without the user's knowledge or consent. This library is designed to make transparent, consensual mining easy:

  • Consent is built in. Mining defaults to off. The application controls when and how to ask the user.
  • Consent and persistence are separate. The user can grant or deny mining, and independently choose whether to remember the decision across sessions.
  • Mining is transparent. The library is open source. Applications using it are expected to disclose mining clearly.
  • The user can build without it. This library is designed to be an optional dependency behind a feature flag. Anyone who builds from source can exclude it entirely.
  • CPU usage is throttled. The default is 25% of available CPU time. This is adjustable at runtime, including by the end user if the application exposes the setting.

Possible distribution model

Distribution Mining Cost
Free binary download Yes Free
Paid version No Paid
Self-built from source No Free

At minimum, the user should be informed through a consent dialog at first launch. Optionally, the mining notice can also appear on the download page or in the project README.

Features

By default, opt-in-miner mines Monero using rust-randomx. Enable the wownero cargo feature to mine Wownero using rust-randomwow instead.

Quick start

Monero (default)

MONERO_WALLET="your-monero-wallet-address" \
MONERO_SOURCES="pool:pool.hashvault.pro:3333" \
cargo build --release

Wownero

WOWNERO_WALLET="your-wownero-wallet-address" \
WOWNERO_SOURCES="node:127.0.0.1:34568" \
cargo build --release --features wownero

In your application:

let mut miner = opt_in_miner::mining_state!("my-app");
miner.start();

The mining_state! macro reads the compile-time environment variables for the active feature (MONERO_* or WOWNERO_*) and constructs a [MiningState]. If no wallet was set at build time, the miner is a safe no-op.

Sources

The MINER_SOURCES string is a comma-separated list of mining sources, each prefixed with node: (solo mining against a daemon's RPC) or pool: (Stratum pool mining):

pool:pool.hashvault.pro:3333,pool:gulf.moneroocean.stream:10001,node:127.0.0.1:18081

The miner tries sources in order and falls back to the next one if a source becomes unreachable.

  • Solo mining (node:) — connects directly to a Monero/Wownero daemon's RPC endpoint. No pool fees, no intermediary. Viability depends on the number of concurrent users and the network hashrate. For Wownero, solo mining is realistic even for small user counts because the network hashrate is much lower than Monero's.
  • Pool mining (pool:) — connects to a mining pool via Stratum protocol (TLS). Steady, predictable income proportional to hashrate. Small pool fee (typically 0–1%). Most Monero pools (HashVault, MoneroOcean, SupportXMR) work out of the box.

Builder API

For full control, use Miner::builder directly:

use opt_in_miner::{ConsentReply, ConsentStatus, Miner, Persistence, Source};

let mut miner = Miner::builder()
    .wallet("your-wallet-address")
    .sources(&[
        Source::pool("pool.hashvault.pro:3333"),
        Source::node("127.0.0.1:18081"),
    ])
    .cpu_fraction(0.25)
    .application_name("my-app")
    .consent_check(|| ConsentReply {
        consent: ConsentStatus::Granted,
        persistence: Persistence::Save,
    })
    .build();

miner.start();
miner.stop();

Feature flag in your application

Make opt-in-miner an optional dependency so users building from source can exclude it entirely:

[features]
mining = ["dep:opt-in-miner"]
wownero = ["opt-in-miner?/wownero"]

[dependencies]
opt-in-miner = { version = "0.3", optional = true }
  • cargo build --features mining — Monero mining
  • cargo build --features mining,wownero — Wownero mining

In your code:

#[cfg(feature = "mining")]
{
    let mut miner = opt_in_miner::mining_state!("my-app");
    miner.start();
}

Users who build with --no-default-features get a binary with no mining code at all.

Runtime settings

All settings can be changed while mining is active:

  • set_consent(ConsentStatus::Granted / Denied) — grant or deny mining permission
  • set_persistence(Persistence::Save / Ask) — remember the decision or ask again each launch
  • set_cpu_fraction(0.5) — change CPU usage immediately
  • set_threads(4) — change thread count (restarts mining)
  • toggle() — start/stop mining, or signal that consent is needed
  • stop() / start() — pause and resume mining

Ethical guidelines for application developers

If you use this library, you are responsible for being transparent:

  1. Ask for consent at first launch. Use the consent callback or MiningState to show a clear, honest dialog. Do not bury it in terms of service. This is the most important step.
  2. Make it easy to opt out. Expose the consent setting in your application's preferences. Let users change their mind.
  3. Keep CPU usage reasonable. The default 25% is a good starting point. Don't set it higher without reason.
  4. Offer alternatives. A paid version without mining, or a self-build option, gives users real choice.
  5. Consider additional disclosure. Mentioning mining on your download page or README is optional but increases trust.

Using this library to mine without the user's informed consent is a misuse of the library and may violate computer fraud laws in many jurisdictions.

Why Monero or Wownero?

Both use the RandomX family of proof-of-work algorithms, which are designed for general-purpose CPUs and resistant to ASICs and GPUs. This means CPU mining is actually viable — unlike Bitcoin or Ethereum, where CPU mining produces effectively zero income.

Wownero uses RandomWOW, a lightweight variant with smaller scratchpad sizes, making it friendlier to lower-end CPUs. Wownero's lower network hashrate also makes solo mining realistic for small applications.

License

Licensed under either of

at your option.