Problem with event listening on transaction receipt/hash

Hi there! I’m working on a web game with Moralis and I have a problem, when the user transfer to buy an item, using the event listener tx.on('receipt, …) there I execute a cloud function that give an item to the user.
The problem is that if the user close his browser before that transaction reach the receipt state, the cloud function never execute.
There is any way to do this on server side to avoid this problem?

Hey @mirindo_dev

This is a backend logic, not a front end. For example you can listen to all transaction to your contract or listen to all transactions of the user. For example if user have a transaction to the target contract you can use afterSave hooks to run a cloud function. It’ll be triggered after a new row added to the Transactions table. Take a look at https://docs.moralis.io/moralis-server/cloud-code/triggers#aftersave

yep, I red the docs again and I could understand it, however I need to do something when the transaction is confirmed, and on the docs only show an event on.(“created”…), there is another event like “confirmed” ?

usually you will have different tables for confirmed and pending transactions
the table for pending transactions usually has pending on its name at the end