Search code examples
ethereumgeth

Ethereum Geth - pending Transactions


My question is: How can I see pending transactions in geth and how can I see my transactions at the blocks? I tried it but I can't see them?

I found the Managment API but I also can't see the pending tx. I also tried to check my old transactions from my wallet address and they are also not shown! Do I need to configure geth in any way? I have not changed anything in the config file!

enter image description here


Solution

  • I believe this is what you need:

    • eth.pendingTransactions
    • eth.pendingTransactions.length

    enter image description here

    Example from my Geth

    enter image description here

    To filter the transactions sent from your address, you can use this snippet:

    m = 796100 // starting block, it's better not start from 0, it's time consuming
    n = eth.blockNumber // the 'latest' block
    
    for (var i = m; i < n; i++) {
        var block = eth.getBlock(i, true);
        for (var j = 0; j < block.transactions.length; j++) {
            if (block.transactions[j].from == "0x...") {
                txs.push(block.transactions[j]);
            }
        }
    }
    

    In below example, I want to catch all transactions sent from 0xebe78a89cecaf67bb79881d7440ba14486d21b7e between block number 796100 to latest block (796297):

    enter image description here

    Notes:

    • Geth works best with one-liner JavaScript code. That's why my JS code above is in one line.
    • Bigger and clearer image is available here.