Skip to content

Instantly share code, notes, and snippets.

@xd4rker
Created April 16, 2018 13:08
Show Gist options
  • Save xd4rker/a3503318cb019d65eebe94c812cca77e to your computer and use it in GitHub Desktop.
Save xd4rker/a3503318cb019d65eebe94c812cca77e to your computer and use it in GitHub Desktop.
web3.eth.getBlock('latest', function(e, r) {
var data = {number: r.number, hash: r.hash, timestamp: r.timestamp };
var sha3 = web3.sha3([data.hash.slice(2), (data.timestamp + 14).toString(16).padStart(64, "0")].join(''), {encoding: 'hex'});
data.answer = parseInt(sha3.slice(-2), 16);
contractInstance.guess(data.answer, {value: 1000000000000000000}, function(x, v) { })
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment