I am programming a button for a transaction which shall only appear if the transaction is possible. Therefore, I am using the following code

  .estimateGas({...},(error,result) =>
      \\ show button

However, there is always a MetaMask error in my javascript console if the transaction would fail. Is there a way to catch this error? I just do not want it to appear in the console.

enter image description here

  • Post the actual ode please (Solidity code of the function, and Javascript code of the arguments that you are passing to estimateGas). – goodvibration May 21 at 17:28
  • Why do you care about the message appearing in the console? – smarx May 21 at 17:36
  • It seems a bit weird to me that an error message pops up only because the transaction is estimated to fail. Hence, I would like to handle this message. I guess there should be a simple JS trick to catch it but everything I tried still was leading to the error message. I tried try{await contract.meth...}catch(err){\\ log err} but it would then show the message of err plus the same error message of MetaMask. – Olympus May 21 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.