I am using web3.js version 0.20.6. I want to find the total transaction count so that I can set my nonce correctly. Currently, I am calculating the number of transactions in the following manner:

getCount = async function(address){

      web3.eth.getTransactionCount(address, async function(err, count){

         var confirmedTransactionCount = count; //this is obtained correctly

         client = new rpc.Client(options);

          {"jsonrpc": "2.0", "method": "txpool_content", "params": [], "id": 1},
          function (err, res) {

                 var pendingTransactionCount = res["pending"][address].length;
                  //here res["pending"][address] is always 'undefined'


As I mentioned, the value res["pending"][address] is always undefined. I can see there are entries for other addresses, however there are no entries for the sender's address I used to create and broadcast a transaction.

I can see that the transaction is in pending state on etherscan. Is it because the txpool_content is specific to a node and the node I am pointing to does not contain my transaction?

PS: there might be some syntactical error in the code snippet here, but essentially this is my code and I have made sure the values in all variables are being set correctly



Browse other questions tagged or ask your own question.