1

I am trying to make my own Ethereum Explorer, I am pretty much near now... Right now I am stuck with Dropped & Replaced Transactions.

Here's TxHash=0x621b5b34ccf2960915b4c4a1bf9a002e33f8b780fe1d04d3649d715ad4517948

In etherscan you can see its Dropped & Replaced, but I can't find it in my Geth node.

I can't find this TX in txPool... Can someone tell me where I can get it from.

enter image description here

My Geth is Fully Synced already.

This is how I am starting Geth::

geth --datadir=/blockchain/ --mainnet --cache=20480 --syncmode "fast" --rpc --rpcport 20590 --rpcaddr 127.0.0.1 --rpcapi="eth,net,db,rpc,web3,txpool,personal,debug,account" --http --maxpeers 200 --txpool.globalslots=250000 --txpool.globalqueue=50000

SOLUTION::

If anyone interested in doing the same... please note you have to first enable websocket in Geth Node, then subscribe to pendingTransaction,logs

  1. Below is how you can listen to upcoming pendingTransactions

    const subscription = web3.eth.subscribe('pendingTransactions', (err,res) => {
      if (err) console.error(err);
    });
    subscription.on('data', (txHash) => {
       setTimeout(async () => {
          try {
             let tx = await web3.eth.getTransaction(txHash);
             if (tx) {
                // Here's your Transaction save it somewhere
             }
          } catch (err) {
             console.error(err);
          }
    })
    
  2. Subscribe to logs, these logs will tells you either transaction dropped, replaced or successful

Use can use filters like fromBlock, toBlock, address, topics if you want only specific transactions details Read more here

var subscription = web3.eth.subscribe('logs', {
    //address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
}, function(error, result){
    if (error)
      console.log(error);
})
.on("connected", function(subscriptionId){
  console.log("connected", subscriptionId);
})
.on("data", function(log) {
  console.log(log);
  // SAVE data to DB
})
.on("changed", function(log) {
  console.log(log);
  // SAVE data to DB
});

There might be other ways too but I want everything realtime just like etherscan so I prefer this way.

1 Answer 1

1

GoEthereum does not expose this information directly.

You need to implement your own mempool watcher that detects transactions that were later replaced by a higher fee.

2
  • You mean I need to track all the pendingTransaction() myself ? Pls explain a bit Commented Jul 8, 2021 at 7:33
  • 1
    Exactly like that. Commented Jul 8, 2021 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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