Coinhive Javascript Monero Miner

Today I want to tell you about a neat thing: Coinhive implemented a Monero miner in JavaScript. It allows you to integrate it in your websites and also to create short links and captchas which take a bit of the user’s CPU power to calculate some hashes.

To test this out a little, I created an account on Coinhive and shamelessly installed the Simple Monero Miner WordPress plugin in this blog. I might remove it again though because I don’t want to annoy my visitors too much 🙂

(Update: I’ve disabled the plugin – site visitors have calculated a whopping 9 379 840 hashes, worth 0.00136453 XMR – that’s about $0.12 at the time of writing!)

There are various way to run the miner. For instance, it can simply be run “headless” by calling a JavaScript function like this:

<script src="https://authedmine.com/lib/authedmine.min.js"></script>
<script>
var miner = new CoinHive.Anonymous('YOUR_SITE_KEY');
miner.start();
</script>

Simple as that. The miner can be throttled so it doesn’t hog 100% of the user’s CPU power.

If you want to mine some Monero for me now, you can also follow this link to a dedicated miner page on authedmine.com. Thanks in advance!

But isn’t it too slow?

Looking at how other cryptocurrencies like Bitcoin, Litecoin or Ethereum are mined today, you might wonder how mining on a CPU with JavaScript might be effective at all. Those currencies are mined using GPUs or specially made ASICs.

Monero, however, uses the Cryptonight algorithm. It is very compute heavy and is designed to run well on consumer CPUs. Of course, running this in JavaScript isn’t exactly efficient, but thanks to modern JS engines it reaches about 65% of the speed of a native miner according to Coinhive’s claims.

I hope you found this remotely interesting and wish you a nice day!