Table created for "watchContractEvent"

If I make the call below to “watchContractEvent” I am seeing a table created, but I also get an error result back. Any idea what this error is?

const options = {
        tableName: "SNOBTokenTransferManual",
        chainID: "0xa86a",
        address: "0xC38f41A296A4493Ff429F1238e030924A1542e50",
        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: false, internalType: "uint256", name: "value", type: "uint256" },
            ],
            type: "event",
          },
        sync_historical: true,
      };
const r = await Parse.Cloud.run("watchContractEvent", options, { useMasterKey: true });
console.log(r)

Output:

"Log":{2 items
"success":boolfalse
"error":string"request.message is not a function"
}

try do update your server to latest version

A restart has resolved this, but I still never get any events when I try to watch events from code. Is anything else wrong with my code above? I run this from the API Console, and the resulting table is created but never syncs any events. I can set this up manually in the Server Details Sync tab and it will correctly pull in historical details.

After you try to add events from code, are there any errors in logs? If you restart the server still doesn’t work?

I do see this warning in the log - that’s it:

Warning: Duplicate cloud functions exist for syncSNOB. Only the last one will be used and the others will be ignored.

What is that syncSNOB?

Good question. An internal name for a job I presume. I am using the tableName “SNOB” so I presume this is the job that should be syncing events for that table. The table exists after I run this code but never gets any events. I have run this code multiple times so I was assuming this warning is related to that.

I can see a job called syncSNOB in the Jobs table. I don’t seem to be able to delete it from the UI.

I also tried this with no luck:

const unwatch = {"tableName": "SNOB"}
const r = Parse.Cloud.run("unwatchContractEvent", unwatch, {useMasterKey:true});

This gives me this result in the JS Console:

"ERROR":{1 item
"message":string"src property must be a valid json object"
}
"Error":{1 item
"result":string"react-json-view error:"
}
"Error":{1 item
"result":string"src property must be a valid json object"
}

Did you try server update/restart?

Yes, I did cycle it a few hours ago and then retryed with the same results.

Can you share your server subdomain/url?

I sent it via direct message.

I realized I was missing an ‘await’ on this one. So it does seem to succeed in the JS Console with revised code:

const unwatch = {"tableName": "SNOB"}
const r = await Parse.Cloud.run("unwatchContractEvent", unwatch, {useMasterKey:true});
console.log(r)

Although even after running this the “syncSNOB” job still exists.

I saw the message, didn’t look yet

1 Like

for now I noticed this strange chain id: eth

you could try to rename it to 0x1, restart server and then try again

Where are you seeing this on the server?

in the dashboard, in events specific table, last column

Brilliant - I didn’t even know about that table. very helpful to compare things and check them. Have to run for a bit now will look more later this evening.,