I am testing whether transactions that I'm signing offline are accepted by the Kovan network. I'm submitting the transactions using Web3.js ([email protected]) as follows:
I connect to my Open Ethereum 3.0.1 node, and then use web3.eth.sendSignedTransaction. According to the documentation, this should return a PromiEvent. However, the events emitted by the submission are not captured and the promise never resolves. The transaction is submitted to the network nonetheless and is valid (it's a simple transaction sending funds from one non-contract account to another). One can find it in any blockexplorer, like for instance etherscan.
The code below does not behave as expected:
function sendTrans(_rawData,_txHash) {
try {
console.log("Before Asynch call");
web3.eth.sendSignedTransaction(_rawData)
.once('transactionHash', function(hash){ console.log("txHash", hash) })
.once('receipt', function(receipt){ console.log("receipt", receipt) })
.on('confirmation', function(confNumber, receipt){ console.log("confNumber",confNumber,"receipt",receipt) })
.on('error', function(error){ console.log("error", error) })
.then(function(receipt){
console.log("trasaction mined!", receipt);
});
console.log("After Asynch Call");
}
catch (error) {
console.log("Error Sending Transaction", error.message);
}
return { response: "OK", transHash: _txHash };
}
// result: the code does not trigger any emitter event. No logging to the console is made.
The code above just hangs, because the promise returned by sendSignedTransaction is never resolved. No event is received either, so the .on('receipt') is never triggered. However the transaction is successfully submitted to the network and mined. So the problem is not with the submission, but rather with the PromiEvent that web3.eth.sendSignedTransaction returns.
Anyone has any idea of why this behavior is happening?
const promiEvent = web3.eth.sendSignedTransaction(_rawData)...
and thenconsole.log(promiEvent)
to ensure you get the right return object.