Created
May 24, 2018 08:52
-
-
Save michielmulders/6309835482c67b27c94f0a5205749057 to your computer and use it in GitHub Desktop.
Blocknumber Watcher Solidity Ethereum
This file contains hidden or 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
function f( blocknumber, to_address, value_) { | |
var filter = web3.eth.filter('latest').watch( | |
function(err, blockHash) { | |
var target=blocknumber; | |
if(web3.eth.blockNumber==target) { | |
filter.stopWatching(); // your function here | |
web3.eth.sendTransaction({to:to_address, from:web3.eth.coinbase, value: web3.toWei(value_,"ether")}); | |
filter = null; | |
console.warn('Block reached'); | |
if (callback) return callback(false); | |
else return false; | |
} else { | |
console.log('Waiting the block'); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment