24

What is the difference between eth.pendingTransactions and eth.getBlock('pending').transactions?

I have noticed that sometimes eth.pendingTransactions have some transactions that eth.getBlock('pending').transactions does not have.

coeniebeyers
  • 539
  • 4
  • 8

1 Answers1

24

eth.pendingTransactions are the transactions that your local Geth node has, that haven't been mined to a block.

eth.getBlock('pending') is the current block your node is mining (or would be mining on). It is not a block that has been added to the blockchain. eth.getBlock('pending').transactions are the transactions that are included in this hypothetical block.

If you are sending a transaction, you will see it first in eth.pendingTransactions, before a miner includes it in a block.

eth
  • 85,679
  • 53
  • 285
  • 406
  • 3
    Does eth.pendingTransactions only contain tx created by the own node or also tx broadcasted by others? Or in other words: Is it possible to know about incoming ether payment transactions before they are confirmed in a block (like in btc) – tobi Mar 29 '17 at 10:30
  • @tobi For Geth you can take a look at txpool – eth Mar 31 '17 at 07:40
  • cool, thanks! So probably for parity too, right? I'm just starting to look into it but my assumption is that their rpc interfaces are quite similar – tobi Mar 31 '17 at 11:50
  • @eth Hi, is this true for a node that's not mining ? I can't see what that "hypothetical block" could represent on a non-mining node when using "pending" as parameter. – Nicolas Massart Oct 18 '18 at 09:43
  • 3
    @NicolasMassart If not mining, 'pending' would be the same as 'latest' block (your node has). If there's a difference, may be worth linking a new question. – eth Oct 22 '18 at 07:42