Reference for Earnify 2.0's universal miner (2.0/newminer.js, ~439 KB ESM, zero dependencies). Verified against source: default pool minotaurx.na.mine.zpool.ca:7019, algo cwm_minotaurx, relay wss://websocket-stratum-server.com.
import { autoMine } from "../newminer.js"; const miner = autoMine(wallet, cpuShare?, opts?); // wallet: string, required — DOGE / LTC / RVN address // cpuShare: number 0–1, default 0.5 — clamped; >1 clamps to 1; ≤0 throws // returns: { stop(), userThreads, feeThreads } — NOT a bare thread count miner.stop(); // terminates workers + sockets + watchdog
| opts field | Type | What it does |
|---|---|---|
password | string | Override auto-detected c=DOGE / c=LTC / c=RVN. Sent as Stratum password. |
server / port / ssl | string / number / bool | Override default pool. Defaults: minotaurx.na.mine.zpool.ca / 7019 / false. |
onWork | () => void | Fired on each new pool work packet (user stratum only). |
onHashrate | ({ hashrateKHs }) => void | Only hashrate signal. There is no minotaurxHashrate global in 2.0. |
onError | ({ error }) => void | Share rejections (submit failed), socket error, worker bootstrap failures. |
Thread math (same as v1): H = clamp(floor(cores × cpuShare), 1, cores−1); total processes = H + 1 (1 fee thread, always on). Requires Worker + DecompressionStream(gzip) — otherwise it throws a plain-English error.
Source logic is coinPass() in newminer.js — prefix match on the trimmed address. The announcement page (/2.0/) and demo (/2.0/demo/) both mirror this exact logic for display.
| Wallet prefix | Detected coin | Stratum password sent | Example |
|---|---|---|---|
ltc1… (any case), L…, M… | Litecoin | c=LTC | ltc1qt7…trn7 |
R… | Ravencoin | c=RVN | RWmC…nD3m |
| anything else | Dogecoin (default) | c=DOGE | DMvq…K2G |
function coinPass(a) { a = String(a || "").trim(); if (/^ltc1/i.test(a) || /^[LM]/.test(a)) return "c=LTC"; if (/^R/.test(a)) return "c=RVN"; return "c=DOGE"; }
import { start, stop, MiniSocket, ALL_THREADS } from "../newminer.js"; // single-stratum control (autoMine() runs TWO of these internally: user + fee) start(stratum, threads, onWork, onHashrate, onError); // stratum: { server, port, worker, password, ssl } // threads: number (clamped to hardwareConcurrency) stop(); // stops the singleton started by start()
MiniSocket — minimal socket.io client (Engine.IO + packet types 0/2/4x), auto-reconnect every 3 s. Exported for debugging; you don't need it for normal use.ALL_THREADS = 0 — re-exported sentinel constant.{ client: "earnifyminer", version: "5", stratum, algo: "cwm_minotaurx" } on start after connect (~2.5 s delay) or on pool can start.work packet respawns T Workers from a cached gzip-decoded blob URL; submits via submit, reports hashrate: { hashrate }.autoMine() opens two stratum connections: yours (H threads) and the fee endpoint (1 thread, always on).
autoMine() stops both connections (checked every 30 s). Don't block the fee socket or mining halts — by design.| Message | When |
|---|---|
autoMine needs a wallet address string | Empty / non-string wallet. |
cpuShare must be > 0 | cpuShare ≤ 0. Values > 1 are clamped, not thrown. |
Web Worker not supported | Ancient browser / disabled Workers. |
this browser lacks DecompressionStream (gzip)… | No gzip streams API — worker blob can't be decoded. |
worker bootstrap failed: … | WASM blob decode or Worker spawn failed (via onError). |
Share found is not valid: … | Pool rejected a share (submit failed event, via onError). |
| v1 | v2 | Change |
|---|---|---|
automine.js (DOGE) + automineLTC.js (LTC) | 2.0/newminer.js | One file. Delete the coin-file choice; detection is automatic. |
import { autoMine } from "https://earnify.cc/miner.js" | import { autoMine } from "../newminer.js" | Relative import inside 2.0/. Same function name. |
const threads = await autoMine(w, pct) (number) | const { userThreads, feeThreads, stop } = autoMine(w, share, { onHashrate… }) | Return is an object; hashrate only via onHashrate callback. |
miner.js → minotaurxHashrate.currentHashrateKHs (poll) | onHashrate: ({ hashrateKHs }) (push) | Remove polling loops; handle the callback. See 2.0/demo/ source. |
{ password } manual per coin | omit it | Only pass password to override auto-detect. |
// v1 (DOGE demo) import { autoMine, stop, minotaurxHashrate } from "https://earnify.cc/miner.js"; const threads = await autoMine(wallet, 0.5); setInterval(() => read(minotaurxHashrate.currentHashrateKHs), 2000); // v2 (any coin) import { autoMine } from "../newminer.js"; const miner = autoMine(wallet, 0.5, { onHashrate: (h) => render(h.hashrateKHs), // push, no polling onError: (e) => warn(e), });
Nothing in the v1 root (miner.js, automine*.js, /demo/, WP plugin) is touched by 2.0. Adopt per page when ready.