Created
July 29, 2017 23:48
-
-
Save gabrielboliveira/7e2d38e065f9208c362c7989066efd94 to your computer and use it in GitHub Desktop.
Claymore Miner API example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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