CoinHive 
Mine cryptocurrencies Monero ( XMR ) and Electroneum ( ETN ) using CoinHive from node.js
New: nowadays you can run this miner on any class based pool .
New 2: now you can mine Electroneum ( ETN ) .
Need a proxy? check coin-hive-stratum.
Install
npm install -g coin-hive
Usage
const CoinHive = necessitate ( 'coin-hive ' ) ; ( async ( ) = > { // Create miner const miner = expect CoinHive ( 'ZM4gjqQ0jh0jbZ3tZDByOXAjyotDbo00 ' ) ; // CoinHive 's Site Key // Start miner expect miner. start ( ) ; // Listen on events miner. on ( 'found ', ( ) = > comfort. logarithm ( 'Found ! ' ) ) ; miner. on ( 'accepted ', ( ) = > console. log ( 'Accepted ! ' ) ) ; miner. on ( 'update ', data = > comfort. log ( ` Hashes per second :${
data
.
hashesPerSecond
}
total hashes :${
data
.
totalHashes
}
accept hashes :${
data
.
acceptedHashes
}
` ) ) ; // Stop miner setTimeout ( async ( ) = > expect miner. stop ( ), 60000 ) ; } ) ( ) ;
CLI
custom :
coin-hive ZM4gjqQ0jh0jbZ3tZDByOXAjyotDbo00
Options :
--username Set a username for the miner
--interval Interval between updates (logs)
--port Port for the miner server
--host Host for the miner server
--threads Number of threads for the miner
--throttle The fraction of time that threads should be idle
--proxy Proxy socket 5/4, for example: socks5://127.0.0.1:9050
--puppeteer-url URL where puppeteer will point to, by default is miner server (host:port)
--miner-url URL of CoinHive's JavaScript miner, can be set to use a proxy
--dev-fee A donation to the developer, the default is 0.001 (0.1%)
--pool-host A custom stratum pool host, it must be used in combination with --pool-port
--pool-port A custom stratum pool port, it must be used in combination with --pool-host
--pool-pass A custom stratum pool password, if not provided the default one is 'x'
API
-
CoinHive(siteKey[, options])
: Returns a predict of aMiner
exemplify. It requires a CoinHive Site Key. Theoptions
object is optional and may contain the following properties :-
username
: Set a username for the miner. See CoinHive.User . -
interval
: interval betweenupdate
events in master of science. Default is1000
. -
port
: port for the miner server. Default is3002
. -
host
: host for the miner server. Default islocalhost
. -
threads
: Number of threads. Default isnavigator.hardwareConcurrency
( issue of CPU cores ) . -
throttle
: The fraction of meter that threads should be dead. nonpayment is0
. -
proxy
: Puppeteer ‘s proxy socket 5/4 ( internet explorer :socks5://127.0.0.1:9050
) . -
launch
: The options that will be passed topuppeteer.launch(options)
. See Puppeteer Docs . -
pool
: This allows you to use a different pool. It has to be an Stratum based pond. This aim must contain the following properties :-
host
: The pool ‘s host . -
port
: The pond ‘s port . -
pass
: The pool ‘s password. If not provided the default one is"x"
.
-
-
devFee
: A contribution to send to the developer. Default is0.001
( 0.1 % ) .
-
-
miner.start()
: plug in to the consortium and beginning mining. Returns a promise that will resolve once the miner is started . -
miner.stop()
: Stop mining and gulf from the pool. Returns a promise that will resolve once the miner is stopped . -
miner.kill()
: Stop mining, unplug from the pool, shutdown the server and close the brainless browser. Returns a promise that will resolve once the miner is dead . -
miner.on(event, callback)
: Specify a recall for an event. The consequence types are :-
update
: InformshashesPerSecond
,totalHashes
andacceptedHashes
. -
open
: The connection to our mining pool was opened. normally happens soon after miner.start ( ) was called . -
authed
: The miner successfully authed with the mine pool and the siteKey was verified. normally happens correctly after open . -
close
: The connection to the pond was closed. normally happens when miner.stop ( ) was called . -
error
: An error occured. In case of a connection error, the miner will mechanically try to reconnect to the pool . -
job
: A new mine job was received from the pool . -
found
: A hash meeting the pool ‘s difficulty ( presently 256 ) was found and will be send to the pool . -
accepted
: A hashish that was sent to the pool was accepted .
-
-
miner.rpc(methodName, argsArray)
: This method acting allows you to interact with the CoinHive miner example. It returns a promise that resolves the the respect of the outside method that was called. The miner example API can be found here. here ‘s an exercise :
volt-ampere miner = expect CoinHive ( 'SITE_KEY ' ) ; expect miner. rpc ( 'isRunning ' ) ; // false expect miner. start ( ) ; expect miner. rpc ( 'isRunning ' ) ; // true expect miner. rpc ( 'getThrottle ' ) ; // 0 expect miner. rpc ( 'setThrottle ', [ 0.5 ] ) ; expect miner. rpc ( 'getThrottle ' ) ; // 0.5
Environment Variables
All the follow environment variables can be used to configure the miner from the external :
-
COINHIVE_SITE_KEY
: CoinHive ‘s Site Key -
COINHIVE_USERNAME
: Set a username to the miner. See CoinHive.User . -
COINHIVE_INTERVAL
: The time interval on which the miner reports an update -
COINHIVE_THREADS
: Number of threads -
COINHIVE_THROTTLE
: The fraction of fourth dimension that threads should be idle -
COINHIVE_PORT
: The port that will be used to launch the server, and where puppeteer will point to -
COINHIVE_HOST
: The host that will be used to launch the waiter, and where puppeteer will point to -
COINHIVE_PUPPETEER_URL
: In case you do n’t want to point puppeteer to the local server, you can use this to make it point somewhere else where the miner is served ( i :COINHIVE_PUPPETEER_URL=http://coin-hive.herokuapp.com
) -
COINHIVE_MINER_URL
: Set the CoinHive JavaScript Miner url. By defualt this ishttps://coinhive.com/lib/coinhive.min.js
. You can set this to use a CoinHive Proxy . -
COINHIVE_PROXY
: Puppeteer ‘s proxy socket 5/4 ( internet explorer :COINHIVE_PROXY=socks5://127.0.0.1:9050
) -
COINHIVE_DEV_FEE
: A contribution to the developer, the default is 0.001 ( 0.1 % ) . -
COINHIVE_POOL_HOST
: A customs stratum pool host, it must be used in combination withCOINHIVE_POOL_PORT
. -
COINHIVE_POOL_PORT
: A custom stratum pool port, it must be used in combination withCOINHIVE_POOL_HOST
. -
COINHIVE_POOL_PASS
: A custom level pool password, if not provided the default option one is ‘ ten ‘ .
FAQ
Can I run this on a different pool than CoinHive’s?
Yes, you can run this on any pool based on the Stratum Mining Protocol .
const CoinHive = necessitate ( 'coin-hive ' ) ; ( async ( ) = > { const miner = expect CoinHive ( '' , { pool: { host: 'la01.supportxmr.com ' , port: 3333 , spend: '' // default ' x ' if not provided } } ) ; expect miner. start ( ) ; miner. on ( 'found ', ( ) = > comfort. log ( 'Found ! ' ) ) ; miner. on ( 'accepted ', ( ) = > console table. log ( 'Accepted ! ' ) ) ; miner. on ( 'update ', data = > console table. log ( ` Hashes per second :${
data
.
hashesPerSecond
}
sum hashes :${
data
.
totalHashes
}
accept hashes :${
data
.
acceptedHashes
}
` ) ) ; } ) ( ) ;
now your CoinHive miner would be mining on supportXMR.com
pool, using your monero address .
You can besides do this using the command line interface :
coin-hive --pool-host=la01.supportxmr.com --pool-port=3333 --pool-pass=
Can I mine other cryptocurrency than Monero (XMR)?
Yes, you can besides mine Electroneum ( ETN ), you can actually mine on any pool based on the Stratum Mining Protocol and any coin based on CryptoNight .
You can go get you ETN wallet from electroneum.com if you do n’t have one .
const CoinHive = ask ( 'coin-hive ' ) ; const miner = expect CoinHive ( '' , { pool: { horde: 'etn-pool.proxpool.com ' , port: 3333 } } ) ; miner. startle ( ) ;
now your CoinHive miner would be mining on etn.proxpool.com
consortium, using your electroneum address .
You can besides do this using the command line interface :
coin-hive --pool-host=etn-pool.proxpool.com --pool-port=3333
One of the features of Electroneum is that it has a difficulty of 100
, while CoinHive ‘s is 256
.
Can I run this on Heroku?
No, it violates the TOS .
besides, since Puppeteer requires some extra dependencies that are n’t included on the Linux box that Heroku spins up for you, you need to go to your app ‘s Settings > Buildpacks
beginning and add this url :
https://vesnice.net/jontewks/puppeteer-heroku-buildpack
On the following deploy, your app will besides install the dependencies that Puppeteer needs to run .
Can I run this on Docker?
You ‘ll need to install the latest version of Chrome and Puppeteer ‘s dependencies in your Dockerfile :
FROM node:8-slim
# Install latest chrome and puppeteer dependencies
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - &&\
sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' &&\
apt-get update &&\
apt-get install -y google-chrome-unstable gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
# Install coin-hive
RUN npm i -g coin-hive --unsafe-perm=true --allow-root
# Run coin-hive
CMD coin-hive
Which version of Node.js do I need?
Node v8+
Troubleshooting
I’m having errors on Ubuntu/Debian
Install these dependencies :
sudo apt-get -y install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libxext6
I’m getting an Error: EACCES: permission denied when installing the package
Try installing the software using this :
sudo npm i -g coin-hive --unsafe-perm=true --allow-root
An error occured Failed to launch chrome!
Try changing chromium ‘s feasible path to /usr/bin/chromium-browser
, like this :
const miner = expect CoinHive ( 'site-key ', { launch: { executablePath: '/usr/bin/chromium-browser ' , args: [ ' -- disable-setuid-sandbox ', ' -- no-sandbox ' ] } } ) ;
For more information assay issue # 54
Read more: Mania For Trading Cards Causes Issues
Disclaimer
This plan is not endorsed by or affiliated with coinhive.com
in any means .
Support
This project is pre-configured for a 0.1 % contribution. This can be easily toggled off programatically, from the CLI, or via environment variables. If you do therefore, but you still want to show your hold, you can buy me a beer with magic trick internet money :
BTC: 16ePagGBbHfm2d6esjMXcUBTNgqpnLWNeK
ETH: 0xa423bfe9db2dc125dd3b56f215e09658491cc556
LTC: LeeemeZj6YL6pkTTtEGHFD6idDxHBF2HXa
XMR: 46WNbmwXpYxiBpkbHjAgjC65cyzAxtaaBQjcGpAZquhBKw2r8NtPQniEgMJcwFMCZzSBrEJtmPsTR54MoGBDbjTi2W1XmgM
< 3