1

i know this question has been asked many times in this forum, but none of them give clear cut answer to the questions. I tried the snippet mentioned in this answer: Common useful JavaScript snippets for geth ; But, it gives me the reply as "undefined" when run in the node.

Can someone please guide me on how i can query the blockchain to get incoming transactions to an address?

Thanks!!

0

You can try this for upcoming transaction in latest blocks, even though I feel that the frequency of watch here is a bit high to use it in any application.


var address = web3.eth.accounts[0];     
var filter = web3.eth.filter('latest');

filter.watch(function(error, result){
    var block = web3.eth.getBlock(result, true);
    console.log('current block #' + block.number);

    if(block.transactions.length)
        for(var index in block.transactions)
            if(block.transactions[index].to == address)
                console.log(block.transactions[index]);
});

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.