2

I have two nodes (A and B) running as peers on a private network . How can i check if there are pending transactions on one node (suppose Node A ) from node B.

Node A has rpc enabled and rpcport is 8001

I wrote a js snippet for node B `

var Web3 = require('web3');

var web3 = new Web3(new Web3.providers.HttpProvider("http://ipAddress:8001"));

var mining_threads = 1;

console.log(web3);

function checkWork() {

    if (web3.eth.getBlock("pending").transactions.length > 0) {
        if (eth.mining) return;
        miner.start(mining_threads);
    } else {
        miner.stop();
    }
}

But this code results in the following error:

err: TypeError: 'XMLHttpRequest' is not a function

And secondly when i log the web3 object above, it shows a property eth which is an object. But this eth object doesnot have pendingTransactions method.

How to fetch the pending transactions from Node A then ?

  • Try to hit 'eth.pendingTransactions' in the terminal – Aniket Mar 22 '17 at 7:59

Your Answer

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

Browse other questions tagged or ask your own question.