In my dapp design I am receiving few user inputs via a form and passing them to a smart contract. Inside the smart contract I am using Oraclize service to timestamp the user inputs. Its a known fact that callback from Oraclize (I am using Wolframalpha) takes a few seconds to send back results which in my cases at times have went up to 30 seconds on few occasions.

Inside my dapp (created using Javascript) how can make the control stay on the form page till response from callback is received and then release notification on the page that transaction is successful. Right now my Javascript logic goes ahead and display the success message whereas in the backend the smart contract is still awaiting callback response from Oraclize.

function saveToBlockchain(params) {
    contract.deployed().then(function(i) {
        from: web3.eth.accounts[0]
      ).then(function(f) {
        $("#msg").html("Transaction completed successfully!");

Please suggest how to implement this type of logic in the dapps.

  • Hi there. You'll probably want to emit an event when the __callback() function is eventually called, and have your JS code listen for that event. You might also want to impose some sort of timeout in case the callback doesn't get called for whatever reason (e.g. insufficient funding in the contract to pay the fee for the callback). – Richard Horrocks Aug 10 '18 at 21:06
  • Thanks @Richard Horrocks for your reply. Yes my contract does emit an event which I catch (via an event listener in my server by searching from block 0 to latest block) and use it to store data in an off-chain mongodb server. My trouble is on the application front end side. Once the user submits the form how can I make the page wait for the event and then delay the 'success' message. I will be grateful if you can help provide some reference code. – tanmay Aug 11 '18 at 4:54

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.