-
Notifications
You must be signed in to change notification settings - Fork 15
Home
A NodeJS based stratum client for communication with stratum pool
$ npm i stratum-client --save
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
handle.shutdown();