I am new in dapps world and I want to deduct balance/points when a user buys an item currently I am unable to update balance because sometimes transaction got failed, dropped, or successes after 30 seconds to 2 minutes time, so how to subscribe or listen to transaction event than I can perform some action.

redeemPoints(from, to, price, (err, res) => {
      console.log(res) //old value of balance 

Thanks in Advance.

closed as unclear what you're asking by Henk, Raghav Sood, Vignesh Karthikeyan, Nicolas Massart, flygoing Sep 4 '18 at 16:32

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Could you please elaborate a bit more on what you are trying to achieve? – Henk Aug 16 '18 at 8:27
  • Actually I wanna deduct point when user buy some product, and I even don't know the transaction is success, fail, or drop transaction taking 1 - 10 minutes time – Umair Ahmed Aug 16 '18 at 8:54
  • @UmairAhmed do you mean that you change the state of another database according to the result of the transaction on the blockchain ? – Nicolas Massart Aug 22 '18 at 9:32

You can use events in the solidity smart contract. In simple terms, the purpose of an Event is to provide JavaScript callbacks in a user interface, which allows you to execute code based on whether or not the event was successful or if it errored.

  • I need to fire an event from ABI and listen on client right ? – Umair Ahmed Aug 16 '18 at 9:23
  • Yes, you need to trigger an event in the smart contract and watch it in a front end. – Soham Lawar Aug 16 '18 at 9:30

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