Watch contract event cloud function

Hello,

The demo code for listening to newly pair created event as follow:
let options = {
“chainId”: “0x1”,
“address”: “0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f”,
“topic”: “PairCreated(address, address, address, uint)”,
“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”: “PairCreated”,
“type”: “event”
},
“tableName”: “UniPairCreated”,
“sync_historical”: false
}

Moralis.Cloud.run(“watchContractEvent”, options, {useMasterKey:true});

leads to the following error which is not really meaningful…

Error: Invalid field name: 3.
at SchemaController.enforceFieldExists (/moralis-server/lib/Controllers/SchemaController.js:1218:13)
at SchemaController.validateObject (/moralis-server/lib/Controllers/SchemaController.js:1391:28)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Easy to reproduce, just create a new server and add the code found here https://docs.moralis.io/moralis-server/automatic-transaction-sync/smart-contract-events#watch-new-smart-contract-event

Can Moralis team look at this please?

Thanks in advance

this filed could have a name

also

this topic should have uint256 at the end and not uint

1 Like

Works better now, thanks!