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.

Revisions

  1. xd4rker created this gist Apr 16, 2018.
    8 changes: 8 additions & 0 deletions getAnswer.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    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);
    });