Skip to content

Instantly share code, notes, and snippets.

@saurfang
Created April 14, 2018 23:06
Show Gist options
  • Save saurfang/5b471bc1de991a154da09306b5e13217 to your computer and use it in GitHub Desktop.
Save saurfang/5b471bc1de991a154da09306b5e13217 to your computer and use it in GitHub Desktop.
// transaction hash of contract deploy
var txHash = '0x75acf5e313e2c06e84d9e2609297b6a6f959773e7a4380daa66cc39ba59d6104';
// get transaction
web3.eth.getTransaction('0x75acf5e313e2c06e84d9e2609297b6a6f959773e7a4380daa66cc39ba59d6104', (err, tx) => {
console.log(tx);
var blockNumber = tx.blockNumber;
web3.eth.getBlock(blockNumber, (err, block) => {
console.log(block);
var timestamp = block.timestamp;
var parentHash = block.parentHash;
var hash = web3.sha3(parentHash + web3.padLeft(timestamp.toString(16), 64), {encoding: 'hex'});
console.log(web3.toDecimal(hash.slice(-2)));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment