I have a problem when I interact with an Smart Contract, from a javascript webapp. I can execute the transaction correctly when the status is confirmed, but I cannot get any error response when it fails.
myfunction.myTrans.sendTransaction(
{ from: web3.eth.accounts[0], gas: gas, gasPrice:gasPrice, to:contractaddress, value:web3.toWei(document.getElementById("price").value, "ether") },
function (error, result) {
if (!error) {
console.log(result);
} else {
console.log("transaction error");
console.log(error);
}
})
When I get an error on Metamask, and I can see it in EtherScan, I don't get any error response in the code. I only get a result when everything goes Ok (transaction confirmed).
Any idea on how to manage transaction errors?
Thanks in advance!
web3
version do you use?