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.
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
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); } })
Subscribe to
logs
, these logs will tells you either transactiondropped
,replaced
orsuccessful
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.