MarcoCiaramella / cpu-web-miner

MIT License
1 stars 3 forks source link

cpu-web-miner

A CPU miner for yespower, yespowerR16, yescrypt, yescryptR8, yescryptR16, yescryptR32, minotaurx and ghostrider POW.

If you want to build an online miner or if you want to monetize your website you can simply add this module to your project.

Install

npm i @marco_ciaramella/cpu-web-miner

Usage

In your frontend add

import * as cpuWebMiner from "@marco_ciaramella/cpu-web-miner";

const stratum = {
    server: "europe.raptoreum.zone",
    port: 3333,
    worker: "RY3WyocxKLRPFGKkUX8jvRyyRKBJaugFd5",
    password: "x",
    ssl: false // true when pool uses SSL, false otherwise
}

cpuWebMiner.start(cpuWebMiner.ghostrider, stratum, true, cpuWebMiner.ALL_THREADS);

Use a bundler like webpack for using the above code in your html pages. Or if you want to use this library directly in your html pages without using a bundler, the following is a complete example

<!DOCTYPE html>
<html>
<body>

<h2>Thanks for using cpu-web-miner</h2>

<script type="module">
import * as cpuWebMiner from 'https://esm.run/@marco_ciaramella/cpu-web-miner';

const stratum = {
    server: "europe.raptoreum.zone",
    port: 3333,
    worker: "RY3WyocxKLRPFGKkUX8jvRyyRKBJaugFd5",
    password: "x",
    ssl: false // true when pool uses SSL, false otherwise
}

cpuWebMiner.start(cpuWebMiner.ghostrider, stratum, true, cpuWebMiner.ALL_THREADS);
</script> 

</body>
</html>

How it works

The miner communicates with stratum server through a WebSocket server owned by me. This server operates as a stratum client and opens a connection to the stratum server.

Fee

Maintaining the WebSocket server has a cost so it keeps 2% of shares as fee.

How to monetize your website

Crypto mining can be used as a monetization tool. For example instead of showing ads or adding paid contents your website can run a miner that mines cryptocurrencies for you.

WARNING

You should warn the user about the background mining. Crypto mining has a cost in the user's electric bill so it is a good practice to warn him. Warn with an alert or with a message in the website.