3

Is there a way I can get all pending transactions to a given address/contract? I could get the confirmed transactions by exploring transactions in recent blocks. But how would I go about getting current pending and unconfirmed transactions to a specific address/contract?

For example, I can go to https://etherscan.io/address/ and I can see "(pending) 6 seconds ago". How does etherscan.io determine this? I'd like to do this myself. Do I need to run a node? A friend mentioned something about a listener, but i'm not sure if that's the right direction.

******* Edit ********

This etherscan API doesn't seem to return any pending transactions. Only ones in a block. But their website clearly shows pending transactions...

http://api.etherscan.io/api?module=account&action=txlist&address=0x1234.....5678&startblock=4271910&endblock=99999999&sort=asc&apikey=KEYGOESHERE
2

Have a look here Understanding transactions better

Full nodes listen and broadcast transactions. As a full node you receive and can display the pending transactions in your transaction pool. That's what etherscan does. Maybe you can't access it through their API, their choice.

So you can get some of the pending transactions as a node, but you don't get to choose, and most likely some transactions will have been included in a block before they reach you in a pending state.

  • Thanks for the link. I'll read up more. So if full nodes don't even see all pending transactions, that would mean that even etherscan's site (which may be running a full node) could not possibly show you 100% of all pending transactions, correct? – LampShade Sep 14 '17 at 7:15
  • Yes, as soon as the transaction is mined in a block, nodes have no reason to keep it in the pending queue nor broadcast them, neither to you or etherscan. – Nicolas Bernard Sep 14 '17 at 9:08
  • I understand a mined block is no longer in the pending queue. I'm asking if: can one node can see all pending transactions on the entire network? And also, does etherscan's website (assuming it's just a window into a full node) not have visibility into all pending transactions on the entire network? So if node A registers a transaction as pending, does node B/C/D see that node A is pending a transaction? – LampShade Sep 14 '17 at 14:29
  • 2
    You don't understand how peer to peer networks work. You are connected to a few peers, themselves connected to a few peers, and you broadcast to your peers, themselves broadcast to other nodes, until something happens. There is NO central storage for pending transactions that you could query. If you were connected to many peers, you would see more transactions coming. You can imagine trying to have all full nodes as peers, there's about 24k. It doesn't mean you would be guaranteed to get all transactions broadcast to you but that's the closest you could do I guess. – Nicolas Bernard Sep 15 '17 at 3:43

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.