Created
April 14, 2018 23:06
-
-
Save saurfang/5b471bc1de991a154da09306b5e13217 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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