Cryptojacking How To

Cryptojacking tutorial

This tutorial is a cryptojacking how-to detailing exactly what you need to setup an opt-in WordPress Coinhive miner for the Monero cryptocurrency.

The 4 basic steps are:

  1. Get a mymonero.com account.
  2. Get a coinhive.com account.
  3. Customize JavaScript code.
  4. Add JavaScript code to your site.

Get a mymonero.com account

  • Navigate to https://mymonero.com.
  • Create an account.
  • Copy down your Private Login Key.
  • Store your Address.

Private Login Key

Cryptojacking How To: MyMonero Private

Address

Cryptojacking How To: MyMonero Address

Get a coinhive.com account

Cryptojacking How To: Coinhive

Customize JavaScript code

Cryptojacking How To: Coinhive Site Key

<script src="https://authedmine.com/lib/authedmine.min.js"></script>
<script>
 var miner = new CoinHive.Anonymous('<YOUR PUBLIC SITE KEY>', {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>

Add JavaScript code to your site

If you’re using a WordPress site, there are WordPress plugins that should make this super easy to configure.

However…

If you don’t want to install yet another plugin to simply add JavaScript to your posts, here’s what I did…

  • Install the Ad Inserter WordPress plugin.
  • Ad Inserter provides many advanced options to insert any JavaScript, CSS, HTML, PHP or advert code anywhere on the page.
  • In your WordPress Admin page, go to Settings > Ad Inserter.
  • Add your JavaScript snippet.
  • Set Automatic Insertion to Before Post.
  • Set the Posts dropdown to Individually enabled. If you want the code on all posts, change this to Individually disabled.
  • Click Save All Settings.
  • Navigate to your post, scroll to the bottom, and enable it in the post.

Ad Inserter settings

Cryptojacking How To: Ad Inserter

Enable Ad Inserter

Cryptojacking How To: Enable Ad Inserter

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 3

    1. Post
      Author

      To get an idea of how Coinhive accomplishes cryptojacking, you could inspect their source code. It’s written in JavaScript, so presumably you could just debug the code that is executing in your browser to get some ideas. Then put together something similar.

      You could also check GitHub for others that may have done this before: https://github.com/search?q=coinhive.

Leave a Reply

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

nineteen − thirteen =

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