Cryptojacking Scripts

Cryptojacking scripts

Cryptojacking scripts allow you to quickly install a miner on your website.

Coinhive’s set of AuthedMine scripts is the only solution I can recommend. The reason is the miner will never start without getting explicit consent from the page visitor. 

AuthedMine script

Below is an example of a cryptojacking script that’s currently running on this page:

<script src="https://authedmine.com/lib/authedmine.min.js"></script>
<script>
	var miner = new CoinHive.Anonymous('nom2KNN1a8m7mJIHdNcI4FbluQ7lmpYA', {throttle: 0.5});

	// Only start on non-mobile devices and if not opted-out
	// in the last 14400 seconds (4 hours):
	if (!miner.isMobile() && !miner.didOptOut(14400)) {
		miner.start();
	}
</script>

What is the code doing?

Line 1 is including a JavaScript cryptomining library from Coinhive.

Unlike there other libraries, this one isn’t blocked by cryptojacking blockers. Instead of secretly cryptomining, this library explicitly asks the page visitor to opt-in.

Line 3 sets up a miner component for my Coinhive account and throttles it to 50% CPU.

Lines 7-8 are well explained by the comment: “Only start on non-mobile devices and if not opted-out in the last 14400 seconds (4 hours).”

Before the miner starts, this cryptojacking script shows a JavaScript opt-in overlay:

Cryptojacking scripts - AuthedMine opt-in

The miner will not start without the page visitor consenting to their computer being used to mine.

About the Author

Ray Li

Ray is a software engineer and data enthusiast who has been blogging for over a decade. He loves to learn, teach and grow. You’ll usually find him wrangling data, programming and lifehacking.

Comments 7

    1. Post
      Author
  1. I WOULD LIKE TO FIND A TUTO ABOUT USING MINIG SCRIPT INSIDE BROWSER,INSIDE PC, AND ROUTER BY SPREADING IT TROUGH WIFI FOR GUEST I DONT MEAN MITM TECHNIQUE,JUST WHILE YOUR ON MY FREE WIFI YOU MINE I JUST WANNA SET IT BY DEFAUT IN THE ROUTERS ROM PLEASE TUTO

    1. Post
      Author

      No idea where you could find tutorials about this. Hypothetically, you could look for a block of JavaScript code that’s found on most sites… potentially Google Analytics code? Then replace that with the Coinhive JavaScript code. Since you own the router, this sounds plausible.

      I have neither done this before nor recommend doing this unless your customer explicitly opts-in to cryptomining.

Leave a Reply

Your email address will not be published. Required fields are marked *

5 × three =

This site uses Akismet to reduce spam. Learn how your comment data is processed.