0

Newbie here, so apologies if this doesn't make much sense.
Is there a way I can simply track and store the transactions issued for verification (I do not care if they end up being validated or not at this instance)?

My guess would be that I would have to run a mining node but not do any mining after all.
Any references for further reading would be much appreciated.

  • Would it be accurate to say you simply want to store all the transactions which enter the transaction pool? – Shawn Tabrizi Jun 22 '18 at 20:02
  • I think this is what I am looking for. Do you know how this transaction pool is collected? Does it combine transactions by many miners, are there any transactions that are not present in this transaction pool and would probably be seen in other transaction pools (if any)? – jonna_983 Jun 23 '18 at 9:02
1

There is no guarantee that any one source will have all possible transactions in their transaction pool.

Pending transactions are shared via the P2P network of nodes, and there is always the chance that a transaction gets mined before it gets all to way around to all nodes, or there might even be transactions that are hidden from the public transaction pool and people are trying to mine on their own.

That being said, using Web3.js 1.0 and WebSockets, you can do a best effort stream of pending transactions using either your own local Ethereum node, or an external node like the ones Infura offer.

I actually talk about this in my blog post: Using Web3.js 1.0 Subscribe and Infura WebSockets to Visualize Ethereum Transactions

The relevant code is here:

var web3 = new Web3('wss://mainnet.infura.io/_ws');

subscription = web3.eth.subscribe('pendingTransactions', function (error, result) {})
    .on("data", function (transactionHash) {
        web3.eth.getTransaction(transactionHash)
        .then(function (transaction) {
            console.log(transaction);
        });
    })

You can see it working here: https://jsfiddle.net/jy2o7p9z/10/

Just open your browser console :)

Let me know if this helps!

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.