NodeJS stratum client

@rnab
1 min readNov 25, 2017

A NodeJS based stratum client for communication with stratum pool

Installation

$ npm i stratum-client --save

Usage

const client = require('stratum-client');
const handle = client({
server: "stratum.slushpool.com",
port: 3333,
worker: "arnabk.1",
autoReconnectOnError: true,
onConnect: () => console.log('Connected to server'),
onClose: () => console.log('Connection closed'),
onError: (error) => console.log('Error', error.message),
onAuthorize: () => console.log('Worker authorized'),
onNewDifficulty: (newDiff) => console.log('New difficulty', newDiff),
onSubscribe: (subscribeData) => console.log('[Subscribe]', subscribeData),
onNewMiningWork: (newWork) => console.log('[New Work]', newWork),
});

server — stratum server to connect

port — port of the stratum server

worker — worker that should be authorized to do the mining

autoReconnectOnError — Whether to reconnect on connection drops

onConnect — Called when connection to server is successfully established

onClose — Called when connection to server is closed/terminated

onError — Any error reported by server

onAuthorize — Called when the worker is authorized. The first parameter is error and the second is result. The first parameter is null when authorization is successful

onNewDifficulty — Called when difficulty is changed

onSubscribe — Called when mining notification subscription is successful

onNewMiningWork — Called when a new mining work is available for the worker authorized above

Shutting down

handle.shutdown();

Reference - https://github.com/arnabk/stratum-client

--

--

@rnab

Typescript, Devops, Kubernetes, AWS, AI/ML, Algo Trading