Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.