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 =)