Ethereum Asked by Arvind on November 20, 2021
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!!
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.
Answered by sp4c3 on November 20, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP