Bitcoin Forum

Bitcoin => Project Development => Topic started by: arnabkar on December 14, 2017, 01:37:48 AM



Title: NodeJS stratum-client
Post by: arnabkar on December 14, 2017, 01:37:48 AM
stratum-client
A NodeJS based stratum client for communication with stratum pool

Installation
Code:
$ npm i stratum-client --save

Code:
const client = require('stratum-client');
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),
});

worker is required in order for onNewMiningWork() to receive new work continuously

Open Source - https://github.com/arnabk/stratum-client/ (https://github.com/arnabk/stratum-client/)