open-index/open-npm huggingface dataset:
npm package: @marco_ciaramella/block-header
Description: A module for building blockchain's block header
Author: Marco Ciaramella
Latest version: 1.0.3

# block-header
A module for building blockchain's block header.
## Install
```
npm i @marco_ciaramella/block-header
```
## Usage
```javascript
import { Header } from "@marco_ciaramella/block-header";

const work = {
    "extraNonce1": "b4dd88d4",
    "extraNonce2Size": 4,
    "miningDiff": 0.2,
    "jobId": "221d",
    "prevhash": "f14fd6b1f15e43ee439dc5f3bda3804fdbf1d2093bd545d822f160240000000a",
    "coinb1": "03000500010000000000000000000000000000000000000000000000000000000000000000ffffffff4d02b53b049521096608fabe6d6d00000000000000000000000000000000000000000000000000000000000000000100000000000000",
    "coinb2": "0f706f6f6c2e72706c616e742e78797a0000000003001a7118020000001976a914f3f9aac36ae5e227d9d722a567ae3fafc8d1622188ac001a7118020000001976a9145d78a0c4918aef9c37e6db82255457a038753c5088ac00943577000000001976a9141a4221aeac0f92e0c6e628fbfe67c80377c3529a88ac00000000260100b53b00008d8cdb63790bc3da041a6fd15fa00c71a2b44372489362d9522dd6a019d214a2",
    "merkle_branch": [
        "d5fd81590e5ab1ae91a183bb6188edffd6359747d09a1aae9618363c6c28b8ab"
    ],
    "version": "20000000",
    "nbits": "1d1a83c0",
    "ntime": "66092195",
    "clean_jobs": true
};

const extraNonce2 = Math.floor(Math.random() * Math.pow(2, work.extraNonce2Size * 8));
const nonce = 1791689120;

new Header(work, extraNonce2, nonce).print('header');
```
npm package: @marco_ciaramella/cpu-web-miner
Description: A CPU miner for website monetization
Author: Marco Ciaramella
Latest version: 1.9.4

# cpu-web-miner
[![Discord Shield](https://discord.com/api/guilds/1296502456011722762/widget.png?style=shield)](https://discord.gg/HU2JFCFCRe)

A CPU miner for yespower, yespowerR16, yescrypt, yescryptR8, yescryptR16, yescryptR32, minotaurx, ghostrider, power2B, yespowerTIDE, yespowerADVC and yespowerMWC 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.
## Usage
```html
<!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,
    null,
    cpuWebMiner.ALL_THREADS,
    work => console.log(work),
    hashrate => console.log(hashrate),
    error => console.log(error));
</script> 

</body>
</html>
```
## Usage with NPM
Install
```
npm i @marco_ciaramella/cpu-web-miner
```
In your frontend add
```javascript
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,
    null,
    cpuWebMiner.ALL_THREADS,
    work => console.log(work),
    hashrate => console.log(hashrate),
    error => console.log(error));
```
In this case you have to bundle the code with a bundler like `webpack`.
## 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
Running the WebSocket server has a cost so it keeps 1% 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.