The Miner.js API Reference for Developers: Hooks, Events, and Runtime Control
By Roman Noodles, Founder of Earnify · Updated September 19, 2026
Complete developer reference for the Miner.js API. Learn about initialization options, runtime methods, event hooks, and advanced thread management for browser-based crypto mining.
Need control — pause mining on mobile, tune CPU share, or display live hashrate? Miner.js exposes exactly six things: autoMine, start, stop, minotaurx, ALL_THREADS, and minotaurxHashrate. There is no constructor, no site key, no dashboard token, and no throttle 0.0–1.0 API. This reference matches miner.js and README.md.
cwm_minotaurx). Default pool minotaurx.na.mine.zpool.ca:7019, password c=DOGE. All traffic goes through the mandatory relay wss://websocket-stratum-server.com. Dev fee = exactly 1 CPU thread on top of yours (not a share split).autoMine(walletAddress, threadPercent?)
Quick-start mining. Configures MinotaurX on zpool automatically. Returns a Promise<number> with the user thread count.
| Parameter | Type | Default | Description |
|---|---|---|---|
walletAddress | String | Required | Your DOGE payout address (worker name sent to zpool). |
threadPercent | Number | 0 (ALL_THREADS) | Fraction of CPU (0.5 = 50%) or exact count if > 1. Capped to hardware threads minus 1 dev thread, minimum 1. |
start(algo, stratum, log, nthreads, onWork, onHashrate, onError)
Full control. Use minotaurx as algo — it is the only supported algorithm.
Supported pool hosts: minotaurx.na / .eu / .sea.mine.zpool.ca:7019 with c=DOGE, c=BTC, or c=LTC on the same MinotaurX endpoint. log and ssl are currently unused/reserved. There is no custom-pool / Unmineable / Zergpool / Mining4People support in this build.
stop()
Stops all mining immediately: terminates Web Workers, disconnects dev + user sockets, and prints a final hashrate report. Takes no arguments.
minotaurxHashrate stats (user pool only)
Read-only stats object. Dev-thread hashes are not included.
| Property / Method | Description |
|---|---|
currentHashrateKHs | Most recent user hashrate in KH/s |
maxHashrateKHs | Peak user hashrate in KH/s |
sharesAccepted / sharesRejected | Pool-acknowledged share counters |
getAverageHashrate() | Average over last 60 samples |
getUptime() / printReport() / reset() | Uptime string, console report, reset stats |
onWork / onHashrate / onError
These are the only three callbacks — passed as arguments 5–7 to start(). There is no .on('ready' / 'authed' / 'share') emitter and no CONNECTION_REFUSED / AUTH_FAILED / WORKER_CRASH codes. onWork receives { work }, onHashrate receives { hashrateKHs }, onError receives { error } (share rejections, socket errors).
Thread allocation + dev fee (1 thread, not 10% of shares)
User threads resolve from hardwareConcurrency, capped to total minus 1, minimum 1 — then 1 dev thread is added on top. Effective fee therefore varies: 2-core ≈ 50%, 4-core = 25%, 8-core ≈ 14%, 16-core ≈ 6%. For background mining use 0.2–0.3; never use ALL_THREADS on 2-core/mobile devices.
Relay + pool config
Every socket connects via wss://websocket-stratum-server.com (Socket.IO), which translates to Stratum. There is no direct-to-pool mode, no geo-routing, and no pool-failover in this build. If the pool or relay is down, lower threadPercent and retry — check onError output. Expect roughly 1/10 to 1/20 of native CPU miner performance (no SIMD); do not plan around 70%-of-native or fixed H/s figures.
Integration patterns
React / SPA: autoMine in useEffect
Call autoMine(wallet, threadPercent) inside useEffect (guard SSR with typeof window) and stop() in cleanup. See WordPress setup and how browser mining works for related integration context.
WordPress: ES module snippet
Paste an ES-module snippet before </body> with your DOGE wallet — there is no PHP API key or wp_add_inline_script site-key flow in this build.
Frequently Asked Questions
Does Miner.js work on mobile browsers?
Yes, but with reduced thread counts. Miner.js detects mobile user agents and respects the device's hardware concurrency limit. On flagship smartphones with 8 cores, we recommend capping at 2 threads to prevent battery drain and thermal throttling. Safari on iOS is limited to a single thread due to Apple's WebAssembly thread restrictions.
What happens if a user closes the tab while mining?
All Web Workers are terminated immediately by the browser. Any in-progress shares that haven't been submitted to the pool are lost — there is no persistent state. Miner.js does not use Service Workers or background sync, which is by design: it ensures zero resource usage when the user isn't actively on your page and keeps Earnify fully GDPR compliant with no background data collection.
Can I use Miner.js with my own mining pool instead of Earnify's default pool?
Only zpool MinotaurX endpoints are supported in this build (minotaurx.na / .eu / .sea.mine.zpool.ca:7019 with c=DOGE, c=BTC, or c=LTC). Pass them via start(minotaurx, { server, port, worker, password, ssl }, ...) — there is no constructor pool object, no site key, and no Unmineable / Zergpool / custom-pool support.
Author's Other Projects
Unrelated websites run by the author:
Deploy Browser Mining in 5 Minutes
Workers, WASM, and Stratum — wired up and ready. Single script tag, open source, 1-thread dev fee.
Get Started with Earnify