I have written a simple web.js program to monitor the pending transactions on the BSC chain and output the tx hash on the console. I want to monitor a specific token, but right now I am outputting every pending transaction.
Then, I go to the bscscan webpage and look at all the transactions in the token of interest. There, I can see in real-time the transactions (there are not too many transactions in that token). I see how new transactions are appearing there, already confirmed. My understanding is that at some point, that transactions have been pending, so I must have seen it in my console, but they do not appear. I have tried with many different WebSocket providers, but I see the same behavior with all of them.
My code:
const Web3 = require('web3')
const web3 = new Web3(new Web3.providers.WebsocketProvider('HERE I HAVE TRIED WITH DIFFERENT WSS PROVIDERS'));
const subscription = web3.eth.subscribe('pendingTransactions', (err, res) => {
if (err) console.error(err)
});
subscription.on('data', (txHash) => {
setTimeout(async () => {
try{
console.log(txHash)
}
catch (err) {
console.error(err);
}
}, 1000)
});
Any idea why I can not see all the pending transactions?