V1 Cloud Functions - Sync active user NFTs

Iโ€™m still using moralis-v1 and I want to run a cloud function to sync ERC721 NFTs of all active users for only specific collection addresses and save data like metadata into the database with each NFT saved.

I am going to write cloud function that I run once to initialize the starting point - Iโ€™m thinking Moralis.Cloud.define is best for a function that will run once?

Then I want another cloud function to watch all user addresses and sync data (add/remove NFTs to database depending on when they are transferred from active wallet addresses).

Am I right to think that itโ€™s best to use the afterSave trigger to run the function after a transfer occurs?

https://v1docs.moralis.io/moralis-dapp/cloud-code/triggers#aftersave

This is how you create cloud functions, it will run as many times as you want if you call this cloud function.

Am I right to think that itโ€™s best to use the afterSave trigger to run the function after a transfer occurs?

afterSave is triggered after the object for that class is saved. It is up to you if you want to use it instead of beforeSave.

You can sync user wallets.

1 Like