0

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 ?

0

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

web3.eth.filter("pending").watch(
    function(error,result){
        if (!error) {
            console.log(result);
        }
    } )

Hope It will Help You...

  • with Infura, I got this error: web3.eth.filter is not a function – jfjobidon Sep 30 at 20:32
  • and with web3.eth.subscribe('pending', ...) I got: Unknown subscription: pending – jfjobidon Sep 30 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 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.