Invalid function: "watchContractEvent" for self-hosted Moralis server

We encountered the following error while running a self-hosted Moralis server.

Server log:
error: Invalid function: "watchContractEvent" { "code": 141, "stack": "Error: Invalid function: \"watchContractEvent\"\n at handleCloudFunction (/usr/src/app/node_modules/parse-server/lib/Routers/FunctionsRouter.js:118:13)\n at /usr/src/app/node_modules/parse-server/lib/PromiseRouter.js:85:20\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)" }

We were calling watchContractEvent Cloud Function via:

import Moralis from 'moralis-v1/node'; Moralis.Cloud.run("watchContractEvent", options, { useMasterKey: true })

Our self-hosted Moralis server is setup following these instructions, specifically this and the server code is from here.Looking the generated Cloud Function codes at build/cloud/ directory (after running yarn build), there is no watchContractEvent generated.

According to the Moralis docs:

Moralis Server has a special cloud function called watchContractEvent(options). You can call it using the master key.

Since Moralis Server (i.e. “Dapp Server”) is discontinued, how do we similarly have this “special cloud function” in our self-hosted server?

For a self hosted server you can use streams api. There is a plugin for a parse server specific to streams api. It will work only for future data and not also for historical data.

do we need a self-hosted server in order to use the NFT API?

No you can use the API directly (HTTP requests) or by using the existing moralis-v1 / react-moralis SDK methods. You can try out our endpoints here also.

2 Likes