Issue using sync events for multiple contracts with same interface

Hey there,

So Iā€™ve got a setup where Iā€™ve got a contract factory which deploys instances of contract B. All instances of contract B have the same interface / abi and I would like to be able to sync events from every instance of contract B to the same table in Moralis.

Iā€™m trying to do this using Moralis.Cloud.run(ā€œwatchContractEventā€) Moralis cloud code at the moment.

It seems to work fine but when I go to sync my second contract I get the error tableName should be unique

Hoping someone can help me with a work around for this, definitely seems like something achievable???

Thanks

I ended up adding a feature request - https://roadmap.moralis.io/b/feature-requests/allow-multiple-syncs-to-be-able-to-post-to-the-same-table

If anyone has a workaround for this which doesnā€™t result in the creation of a table for every contract, Iā€™d love to hear it,

Thanks

You have to use coreservices_ prefix for the cloud function and to remove the address that you want to sync and it will sync that event for any contract.

Thanks Iā€™ll check this out

So do you mean I run the function like so:

Moralis.Cloud.run(ā€œcoreservices_watchContractEventā€, options, { useMasterKey: true });

Canā€™t seem to get it to work, Iā€™ve removed the current sync and deleted the related table and tried re-running the sync without a contract address in the options. Can you please confirm how / where I use the coreservices_ prefix?

it seem ok, what happens?

@cryptokid getting the error:

Error: Invalid function: ā€œcoreservices_watchContractEventā€

ok, it is called coreservices_addEventSync

1 Like

Perfect! Thanks heaps for that.

Is there any documentation or any way to find out more about the core services?

there isnā€™t that documentation about coreservices, that is an internal component to the server

1 Like

Heys bro having the same problemā€¦ Did you find any solutions

Try the solution described above to see if it works for you

But in Cloud function only 100 data is returned , i have data of 1M

That seems like a different question. You can find the answer in other similar forum posts or create a separate forum thread.