I use Infura to get all pending transactions from Ropsten:

web3.eth.subscribe('pendingTransactions', async (error, txHash) => {
    let tx = getTransaction(txHash)

With this subscription, I receive only the transaction hashes, so I must make a request to get each transaction.

My question: is there a way to receive the full pending transactions with a simple subscription ?


There is a filter function in web3 javascript API and you can get pending txs by it. A simple print script as follows:

        if (!error) {
    } )

Hope It will Help You...

  • 1
    with Infura, I got this error: web3.eth.filter is not a function – jfjobidon Sep 30 '19 at 20:32
  • and with web3.eth.subscribe('pending', ...) I got: Unknown subscription: pending – jfjobidon Sep 30 '19 at 20:35
  • It appears you are using web3.js v1.0 and make sure you are using callback with the subscribe method. For more see web3js.readthedocs.io/en/v1.2.0/… – Mahesh Rajput Oct 1 '19 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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