I have a webapp that calls a smart contract via web3js/Metamask and I want to reload certain elements once the user has submitted the tx.

How can I set up the callbacks for those reload actions?

1 Answer 1


All metamask calls suppose to have callback function where you can do whatever you want. Below is the sample snippet for your reference.

myContractInstance.method(parameter,{ from:result[0],
                            value:  0, 
                        }, function(err, transactionHash) {
                            if (!err)
                                $('#info').html("Transaction succeeded. Track <a href='https://rinkeby.etherscan.io/tx/"+transactionHash +"'>"+here+"</a>");
                                console.log('Error in the method');

You can even have ajax call within if(!err) to save or record any other action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.