Unable to save multiple contract addresses/events to a single table

This didnā€™t work for me, and no errors were produced. Did you literally mean coreservices_addEventSync, or some other command? I also tried watchContractEvent but it complained about the missing address.

Would be nice to have central list of available functions, and explicit examples for somewhat obtuse devs such as myself. :laughing:

FYI, Iā€™m referencing Watching from Code

you have to use the command that I pasted to work without an address, watchContractEvent will not work without an address specified

there isnā€™t now a way to list the events with a simple command/function, you can look in the database and see the events saved in a specific table, you can query that table

I did this and receive:

{ status: 200, data: { success: true, result: true } }

Documentation says I wonā€™t see the results in the ADMIN UI, but I will see them in the DB. I donā€™t see them in either place. Note that I do see my previous watchContractEvent items.

you have to use a different table name, to make sure the parameters have the right values, you will see them in both places when it works

Yes, each time Iā€™ve used COMPLETELY different names that follow all the rules, yet still nothing.

My last two table attempts (neither of which exist) were ā€œUniswapvtwoETHā€ and ā€œUniswapvthreeETHā€ . . . both returned 200, but nothing showed up in the panel.

Again, this is a case where an explicit example would be helpful ā€“ because Iā€™m obviously missing something.

you have a working example for watchContractEvent ?
in case that you have, changing that name to coreservices_addEventSync should work without issues

Yes, all of my watchContractEvent work. Not so for coreservices_addEventSync. As Iā€™m receiving no errors, or anything in the logs, Iā€™m not sure what else to look for.

Is there a maximum number of syncs? I currently have 9 watchContractEvent already. Is 9 the max? Is there anything else at all that I should be looking for? Really need more detailed feedback from API events.

I am passing the following:

const options = {
        chainId: _chainId,
        topic: _topic,
        abi: _abi,
        tableName: _tblName,
        sync_historical: false,
      };

. . . same as watchContractEvent minus address. Different abi events as well, that match the topic. Iā€™ve also tried topic as a hash and the function signature. Nothing changes. I receive 200 with no other indication that anything happened.

here is could be an issue, if one of those ABIs is invalid or if it has _ in names

there isnā€™t a limit of 9 events, but if one event has an invalid abi, then the serve will get stuck there

Is there anything about this options that shouldnā€™t work?:

{
  "chainId": "1",
  "topic": "0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822",
  "abi": [
    {
      "anonymous": false,
      "inputs": [
        { "indexed": true, "internalType": "address", "name": "sender", "type": "address" },
        { "indexed": false, "internalType": "uint256", "name": "amount0In", "type": "uint256" },
        { "indexed": false, "internalType": "uint256", "name": "amount1In", "type": "uint256" },
        { "indexed": false, "internalType": "uint256", "name": "amount0Out", "type": "uint256" },
        { "indexed": false, "internalType": "uint256", "name": "amount1Out", "type": "uint256" },
        { "indexed": true, "internalType": "address", "name": "to", "type": "address" }
      ],
      "name": "Swap",
      "type": "event"
    }
  ],
  "tableName": "UNISWAPvvETH",
  "sync_historical": false
}


As I mentioned, I also tried using the ā€œSwapā€ signature text for topic as well to no avail. I use the exact same setup for Transfer() with my watchContractEvent and they work just fine.

What am I missing?

Try first to add an event sync with watchContractEvent with an address to see that everything works and then move to coreservices_addEventSync

It would appear that something is wrong with my server. I just deleted one of my watchContractEvent items and attempted to recreate it . . . first with the original name, but then with a new name, and it responded with 200 and {success:true}, but itā€™s not showing up.

Iā€™ve also tried restarting the dapp (in the event that even matters), but it didnā€™t seem to have any effect.

EDIT

Ok, yes, definitely something wrong with the server. Itā€™s no longer allowing me to delete syncs either.

What is the server url?

Currently testing (failing) on:

wxecd4cxdizd.usemoralis.com

there is an event with an invalid abi on that server, it is not going to work with any new event sync until that is fixed

it could be this one: UNISWAPvTWOBSC, I didnā€™t check exactly

Good to know. Thanks.

Now, how do I access whatever you accessed to see that? I need to be able to view/troubleshoot these things on the fly.

Also, as you can probably see from my watchContractEvent events, I tend to generate random names (especially in dev). Does every single error of this type show up in the log? I need the ability to CRUD without worrying about a local list of items getting out of sync and never being able to track down which item caused what.

I see the name of that ā€œtableā€ in the log, but nothing that clearly indicates an error.

you donā€™t have direct access to what I saw for that event sync, if you add valid abi it should work, but if you add an invalid abi sometimes, like type function instead of type event, everything will stop working at that moment

. . .well, thatā€™s unfortunate. This is yet another reason we need a Moralis.listTables() (or the like) in order to ā€œnukeā€ everything in the event that something bad happens. Obviously a UI would be better, but Iā€™d take access through code.

Any ETA on how long before developer access ā€œimprovesā€?

In few months the plan is to open source the server part, to have an API specific for syncing data. At that time you will have full control.

Excellent!

FYI, finally found that my issue was due to passing the entire ABI (or even the event by itself) enclosed as an array. So it wasnā€™t that it was an invalid ABI, but rather, that the coreservices_addEventSync only wants the exact ā€œsignatureā€ (despite also providing the topic). Iā€™d been making use of the entire contract ABI throughout my application for other things. It wasnā€™t absolutely clear to me (especially since watchContractEvent didnā€™t complain) that I must ONLY pass the specific event portion as an object (not an array, string, or otherwise).

NOTE: I was unable to ā€œfixā€ it. I ended up having to create a new dApp and go from there. All seems good now.

1 Like