General recommendations for clouds functions

Hi guys,
Could you pls give some general recommendations for cloud functions? Which functions should best be on clouds, which one better not? and any thing else needs to be considered?

There are certain things that MUST go in Cloud Functions:

  • Any operation that requires the master key. For security reasons these should always be done on the server side to avoid risk of exposing the master key (think of the master key like your server “private key”)
  • Queries involving aggregates (these are not supported client side)

In general:

  • It’s good to offload as much data processing as possible to the server.
  • Anything you would put in a back end API is a good Cloud Function candidate (as long as it doesn’t need a 3rd party library). You can think of Cloud Functions as endpoints (and they can accessed as such via REST calls)
  • While Triggers are not Cloud Functions they are also “Cloud Code” and are defined in the same place as Cloud Functions. These can be used in combination with the “Sync and Watch Contract Events” plugins to handle more complex use cases like performing some action when a new contract event happens (an afterSave trigger)
  • Web3 functions are available inside Cloud Functions (see here)

Docs for reference:


thank you @mayjer very good advices