Skip to content

Instantly share code, notes, and snippets.

@michielmulders
Created May 24, 2018 08:52
Show Gist options
  • Save michielmulders/6309835482c67b27c94f0a5205749057 to your computer and use it in GitHub Desktop.
Save michielmulders/6309835482c67b27c94f0a5205749057 to your computer and use it in GitHub Desktop.
Blocknumber Watcher Solidity Ethereum
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