watchContractEvent fails with no Error Message - only { "success": false}

Can anyone see why this code does not lead to a watch being created?

I tried it on a brand new server running 0.0.359: https://kqmvn0wwisqp.usemoralis.com/

const options = {"tableName":"UniswapTwoUniswapPairPairCreated",
"chainID":"0x1",
"address":"0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f",
"topic":"0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9",
"abi":{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token0","type":"address"},
{"indexed":true,"internalType":"address","name":"token1","type":"address"},
{"indexed":false,"internalType":"address","name":"pair","type":"address"},
{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],
"name":"UniswapPairCreated","type":"event"},
"sync_historical":false}

  // unwatch 
  //const wce = await Parse.Cloud.run("unwatchContractEvent", options, {        useMasterKey: true,  });

  // Watch
  const wce = await Parse.Cloud.run("watchContractEvent", options, {useMasterKey: true,});
console.log(wce)

The result is:

"Log":{1 item
"success":boo lfalse
}

The lack of any error message makes it very hard to debug what is happening on the server.

Log Output:

2022-03-21T16:32:12.451Z - Ran cloud function watchContractEvent for user undefined with:
  Input: {"tableName":"UniswapTwoUniswapPairPairCreated","chainID":"0x1","address":"0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f","topic":"0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9","abi":{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token0","type":"address"},{"indexed":true,"internalType":"address","name":"token1","type":"address"},{"indexed":false,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"UniswapPairCreated","type":"event"},"sync_historical":false}
  Result: {"success":false}

You could try to give it a name in the abi here, don’t know if this is the problem.

You could try to also add it in the interface where it may have an error message.

I tried adding a name for that field in the ABI but get the same result.

When I use the Management UI and input all the same options and the identical ABI it works.

Log result from running this via the management UI:

Ran cloud function coreservices_addEventSync for user undefined with:
  Input: {"chainId":"0x1","address":"0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f","tableName":"UniswapTwoUniswapPairPairCreatedM","topic":"0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9","abi":{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token0","type":"address"},{"indexed":true,"internalType":"address","name":"token1","type":"address"},{"indexed":false,"internalType":"address","name":"pair","type":"address"},{"indexed":false,"internalType":"uint256","name":"info","type":"uint256"}],"name":"UniswapPairCreated","type":"event"},"filter":"","sync_historical":false,"description":"UniTest"}
  Result: {"status":200,"data":{"success":true,"result":true}}

Maybe I should be calling coreservices_addEventSync somehow from my Cloud code?

This syntax should work:
https://docs.moralis.io/moralis-server/automatic-transaction-sync/smart-contract-events#watch-new-smart-contract-event

Oooff…its “chainId” NOT “chainID”.

That’s -1 for me and maybe -0.5 for the platform not having any error message!

1 Like