1

How would I go about monitoring pending transactions in real-time? Would I be able to monitor only one function?

I have a full node running and have a nodejs (express server) that I want to have this info available to.

I am guessing that a websocket would be the way to go, in which case what would I be listening for?

1
  1. You can create a stream of pending transactions using web3.eth.subscribe('pendingTransactions' [, callback]);, which currently returns a transaction hash.
  2. You can turn into the actual transaction object using web3.eth.getTransaction(transactionHash [, callback]), which will return a transaction object.
  3. You can then filter the returned object by to and input to find only the transactions that are being sent to a specific contract address and are calling a specific function in that contract.
  • 1
    Thanks. I ended up coming to the same conclusion myself. It would be nice if pendingTransactions subscription return the full object as per the documentation ;) – adam May 25 '18 at 3:26
  • in the input field - what exactly am I looking for? Each transaction is different it seems. – adam May 25 '18 at 3:50

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.