trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 678 forks source link

How to listen on mempool #3726

Closed leeeddin closed 2 years ago

leeeddin commented 2 years ago

Hi, Is there any way to listen to the mempool of my local ganache node?

I tried to use web3.eth.subscribe('pendingTransactions', function (error, result) {...}) but it's not working as expected. Usually, when we do that under geth it will print out the tx info(tx hash, if we use web3.eth.getTransaction to get the tx it will also give us other info without block number, block hash, because the tx is not mined) as soon as a tx enters the mempool. But under ganache, it only printout the full tx info(tx hash, block number and block hash) when the tx is mined.

So is there any way to listen to ganache's mempool and get pending tx's info?