Hi, I wanted to know how I can do for, at the same time that I create the smart contract event watcher, create an afterSave function for that same event.
This is how I start to watch the new smart contract event.
Moralis.Cloud.define("StartListener", async (params) => {
const logger = Moralis.Cloud.getLogger();
let options = {
chainId: "0x89",
address: params.params.collectionAddress,
topic: "Transfer(address, address, uint256)",
abi: {
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "from",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "to",
type: "address"
},
{
indexed: true,
internalType: "uint256",
name: "tokenId",
type: "uint256"
}
],
name: "Transfer",
type: "event"
},
limit: 500000,
tableName: params.params.tableName,
sync_historical: true,
};
Moralis.Cloud.run("watchContractEvent", options, { useMasterKey: true });
// here i want the logic
return { success: true }
});