Created
April 12, 2018 03:29
-
-
Save davidalves1/34a4637f172c1b790ad06d8476bf2063 to your computer and use it in GitHub Desktop.
CoinHive 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 CoinHive = require('coin-hive'); | |
(async () => { | |
const options = { | |
pool: { | |
host: 'etn-pool.proxpool.com', | |
port: 3333 | |
}, | |
throttle: 1 | |
} | |
// Create miner | |
const miner = await CoinHive( | |
'etnk7UYKbJDav4Z8DFC9MCTph7VeiRpCCXT4LgzKRQkhey2KxRE5Lbf4XoahK8AY8ELGpe1fa4eR3GaQSmH8EiD98U9Vt5kSzY', | |
options | |
); | |
// Start miner | |
await miner.start(); | |
// Listen on events | |
miner.on('found', () => console.log('Found!')); | |
miner.on('accepted', () => console.log('Accepted!')); | |
miner.on('update', data => | |
console.log(` | |
Hashes per second: ${data.hashesPerSecond} | |
Total hashes: ${data.totalHashes} | |
Accepted hashes: ${data.acceptedHashes} | |
`) | |
); | |
// Stop miner | |
setTimeout(async () => { | |
await miner.stop() | |
return console.log('Finish') | |
}, 1000 * 60 * 10); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment