Skip to content

Instantly share code, notes, and snippets.

@gabrielboliveira
Created July 29, 2017 23:48
Show Gist options
  • Save gabrielboliveira/7e2d38e065f9208c362c7989066efd94 to your computer and use it in GitHub Desktop.
Save gabrielboliveira/7e2d38e065f9208c362c7989066efd94 to your computer and use it in GitHub Desktop.
Claymore Miner API example
const net = require('net')
let socket = new net.Socket()
const req = '{"id":0,"jsonrpc":"2.0","method":"miner_getstat1"}'
const ipAddress = '127.0.0.1'
const port = 3333
socket.setTimeout(1000)
socket.on('connect', () => {
socket.write(`${req}\n`)
sendCommand()
})
socket.on('data', data => {
console.log('Data received: ', data.toString('utf8'))
console.log()
socket.end()
})
socket.on('error', error => {
console.error('An error occurred: ', error)
})
function sendCommand () {
setTimeout(() => {
socket.connect(port, ipAddress)
}, 1000)
}
sendCommand()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment