1

This is my code:

    contractNoEvents.methods.myMethod().call(function(err,foo){
           if (foo.length > n) {
             contractNoEvents.methods.myOtherMethod().call(async function(er, bar){
               if (bar.length > 10){


                var nonce = await web3.eth.getTransactionCount(account);
                const encoded_tx = contractNoEvents.methods.mySendMethod(Math.floor(n).encodeABI();
                const rawTx = {
                     nonce: nonce,
                     gasLimit: 3000000,
                     gasPrice: web3.utils.toHex(utils.toWei('20', 'gwei')), 
                     data: encoded_tx,
                     from: account,
                     to: contractAddress
                }

                let tx = new Tx(rawTx);
                tx.sign(pvtKey);
                let serializedTx = tx.serialize();
                console.log(serializedTx);
                web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
                .on('receipt', console.log)
                .on('error', console.log);
               }
              });
           }
        });

I get the following error on Ropsten:

connection not open on send()
(node:1983) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 13): Error: connection not open

I've been looking around but could not find anything I'm absolutely clueless if anyone has any solutions please =)

0

So the issue was the fact that

var nonce = await web3.eth.getTransactionCount(account);

Was not accepted anymore when uploaded to ropsten somehow. I replaced it with:

web3.eth.getTransactionCount(account).then(_nonce => {
  // insert the transaction signing function
}

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.