Function web3.eth.sendTransaction
can throw an error.
For example:
Transaction gas is too low
Transaction execution error
But can it possibly throw an error before emitting the transactionHash
event?
I am pretty sure that the two errors above cannot possibly occur at this point.
Am I right?
What about other errors?
For example, what if there's a network problem, or an Ethereum-client problem?
Here is a coding example (taken directly from the docs), with the question embedded:
web3.eth.sendTransaction({
from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe',
to: '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe',
value: '1000000000000000'
})
.on('transactionHash', function(hash){
// Can it possibly throw an error before reaching here?
})
.on('receipt', function(receipt){
...
})
.on('confirmation', function(confirmationNumber, receipt){ ... })
.on('error', console.error); // If a out of gas error, the second parameter is the receipt.
Thank you!