Skip to content

Instantly share code, notes, and snippets.

@ylv-io
Last active October 15, 2018 17:28
Show Gist options
  • Save ylv-io/00aabc7f42f2fe04f22ca76be3428cb9 to your computer and use it in GitHub Desktop.
Save ylv-io/00aabc7f42f2fe04f22ca76be3428cb9 to your computer and use it in GitHub Desktop.
try {
const account = getAccount();
const hash = await yourContractInstance.yourMethod.sendTransaction(arg1, arg2, {
from: account,
// if payable, specify value
// value: web3js.toWei(value, 'ether')
});
// update progress UI
setSubmitting(false);
// reset transaction related form, if any
resetForm();
}
catch(e)
{
// if user cancel transaction at Metamask UI we'll get error and handle it here
console.log(e);
// update progress UI anyway
setSubmitting(false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment