Sync contract events automatically


I managed to add watcher for several contract addresses to store their transfers in each their own database table (yes, including historical).

Is there a way to schedule a job to keep them in sync “in an automated way”? From my understanding, by default, these tables will not continuously be filled because the event syncer is not fired - only if I do it manually or schedule a sync in the web interface. I would find it extremely convenient if this could be possible by an API or CLI or a parameter added to the initial createWatcher request.

Alternatively firing the job via a command (I am using moralis/node) would be satisfying enough as well (e.g. utilizing“syncTABLENAME”)?)

Thanks for any help.

you want to add an event sync from code?

what is not in sync?

I think I am figuring it out.

What I am doing is creating a createWatcher/watchContractEvent request from code to get the transfers of a contract/token address into a table. This will not create any scheduled sync, right? Afterwards I will now call database-server/server/cloud_code/jobs with a job_schedule call to create the sync job. I was just hoping there would be a more straightforward way to do so.

I would expect to sync automatically after you add an event sync or watch address

Alright, it just confused me because it did not show any job in the schedule jobs overview for those.

I believe my server crashed some days ago (almost unresponsive and slow, an upgrade/restart helped), thats why it was not synced up yet. But it seems like it is doing it now without those jobs.

1 Like