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:

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 10

    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.

  2. I have an antivirus software on my computer and as soon as i visited this site, it tells me “Threat Quarantined” letting me know that a CoinHive file would like to run on my computer, with the website never asking permission.

  3. Once we opt-in for letting the browser mine, for how long do the mining codes run?
    Until we are on the page or is there a specific time cap?

Leave a Reply

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

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