Skip to content
Arnab Karmakar edited this page Nov 25, 2017 · 8 revisions

NodeJS stratum client

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, required

port — port of the stratum server, required

worker — worker that should be authorized to do the mining, required

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();
Clone this wiki locally