Is it better if cloud function call contract method

In my application I want my end-user to pay some polygon tokens to the wallet of the contract owner to unlock certain game features.
I want to know if this is a good structure or not if I write a cloud function and call the transaction method of the contract. And then any of my app users call that cloud function with the sender address and the amount to pay. Or I should directly call the contract method from my app, without using any cloud function?
The reason I want to use the cloud function is to receive a response and then add the transaction response to a database table.

It is not recommended to call smart contract write function in cloud code as it requires the use of private key.

You can emit events from the contract to track the smart contract data by syncing the contract events to the database.

1 Like

@johnversus Thanks for replying. You are right.