Manage and sync events from multiple contracts is currently really hard and manual

Hello, this one is a bit long, so I made a few diagrams, basically, our use case is, we are deploying smart contracts for various artists, each contract is unique, but they have a common interface that allows them to be reusable on our platform, they also send common events.

We are going to deploy around 1-2 new contracts every week, and right now to manage to sync these events is a very manual task in Moralis, and is not very scaleable, I suggest small improvements that may allow the automation of some parts and an easier scaling of others,

This is the current situation:

  1. we have multiple contracts with the same event - same signature, same ABI.
  2. to sync them with Moralis we need to manually make a sync on the dashboard - it would be nice to expose an API for this? then we can automate the creation of this syncing.
  3. Each sync event needs its own table, this is not easily scalable and we will start losing track when we have hundreds of tables, can we make all the sync events just go to the same table? since they come from different contract addresses it shouldn’t be an issue to identify them.
  4. since we need a new table for each event right now, that means we also need a new webhook for each of them, but outside of Moralis we only have a single service with a single endpoint to consume all of these webhooks.

This leads to a lot of manual work, the diagram for managing these looks something like this:

I suggest some changes, all that needs to be done to make this more scalable, is to:

  1. expose the API you use to create new sync events
    2.A. allow syncing events from multiple contracts to the same table
    2.B. if A is too complicated because of the data structure, how about exposing an API to register webhooks programmatically?

- By “exposing an API”, I mean, you already have an API, it just requires a token that we get by logging in, I’d imagine using something like the MasterKey instead.

3 Likes

@cryptokid any chance you can comment on this? I really value your opinion =)

there is an API to do that: https://docs.moralis.io/moralis-server/automatic-transaction-sync/smart-contract-events#watching-from-code

the part with multiple events using same table is not possible now

2 Likes

Thanks, that’s very helpful, is there also a way to create webhooks by code?

maybe this works: https://seelyn.gitee.io/docs/rest/guide/#create-trigger-webhook

We are too in need of at least one of the ideas proposed above.

It would be a great feature to be able to add multiple contract addresses with identical ABIs to sync into a single class table.

2 Likes

It would be a great feature to be able to add multiple contract addresses with identical ABIs to sync into a single class table.

totally agree with this!

you could propose it on roadmap.moralis.io

2 Likes

@cryptokid I tried out the link (https://seelyn.gitee.io/docs/rest/guide/#create-trigger-webhook) by calling this curl request:

curl -X PUT \
  -H "X-Parse-Application-Id: <APPLICATION_ID>" \
  -H "X-Parse-Master-Key: <MASTER_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://api.example.com/_baz", "class": "TokenMintedEvents"}' \
  https://1nvxhrqd4tbl.usemoralis.com:2053/server/hooks/functions/afterSave

but i get the following response:
{"code":143,"error":"no function named: afterSave is defined"}

Any pointers please?

What were you trying to do?

@cryptokid: Per the original post from @liron, do we have any update on the ability to sync events from multiple contracts with the same ABI & same signature to be synced to a single table?
We have a scenario similar to the original post. Are there any guidance on how this can be accomplished?
Thanks in advance for your suggestions/ comments on this.

that is possible now, but soon you can use streams API for that: moralis.io/streams

@cryptokid the goal is to be able to create a sync & associated webhook from script(s).

re: streams: i’ve signed up for the Streams API early access last week, but have not received any response yet.

Streams API should be released soon (probably this week).

1 Like