Skip to content

Instantly share code, notes, and snippets.

@xd4rker
Created April 16, 2018 10:18
Show Gist options
  • Save xd4rker/6fd01c797303dd1b38ab0eb03891ce5a to your computer and use it in GitHub Desktop.
Save xd4rker/6fd01c797303dd1b38ab0eb03891ce5a to your computer and use it in GitHub Desktop.
var data = {};
web3.eth.getBlock(3045393, function(err, res) {
data.parentHash = res.parentHash;
data.timestamp = res.timestamp;
var answerHash = web3.sha3([res.parentHash.slice(2), res.timestamp.toString(16).padStart(64, "0")].join(''), {encoding: 'hex'})
data.answer = parseInt(answerHash.slice(-2), 16);
console.log(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment