Error when running plugin to sync contract event

Hi all.

I have done the “Deploy and Track ERC20 Events” tutorial and got an error after adding the plugin to Sync MOR Transfer Events.

https://docs.moralis.io/guides/deploy-and-track-erc20-events#syncing-and-watching-contract-events-from-moralis

The MORTranferEvent table was never created, so I checked Logs and got this error:

2021-05-23T20:01:12.782Z - Error syncing syncMORTransferEvent "Cannot read property 'forEach' of undefined" TypeError: Cannot read property 'forEach' of undefined
    at decodeLog (/moralis-server/lib/cloud-code/plugins/helpers/events.js:152:14)
    at historicalUpsertParams (/moralis-server/lib/cloud-code/plugins/helpers/events.js:123:75)
    at /moralis-server/lib/cloud-code/plugins/helpers/events.js:40:9
    at Array.map (<anonymous>)
    at upsertLogs (/moralis-server/lib/cloud-code/plugins/helpers/events.js:36:44)
    at /moralis-server/lib/cloud-code/plugins/evm/events.js:135:15
    at seekPage (/moralis-server/lib/cloud-code/plugins/evm/historical/api.js:95:13)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async SyncJob.sync (/moralis-server/lib/cloud-code/plugins/evm/events.js:133:5)
    at async SyncJob.execute (/moralis-server/lib/cloud-code/plugins/helpers/sync.js:34:7)

I tried to run it manually from Jobs and got the error again.
Any help?

Server url: https://3zll8mgpbesj.moralis.io:2053/server

Thanks,
Murilo

Hi Murilo,

  • Try updating your Moralis server to the lastest version by pressing the “Update / Restart” button on the server.
  • Double check you have the correct contract address for the plugin. The address of YOUR deployed contract will be different than the one in the tutorial example

If that doesn’t fix the issue then post all your code and plugin settings here so it’s easier to help you debug.

FYI the “dapp in 3 minutes” tutorial finished at “Could Functions - Part 5”… the “Deploy and Track ERC20 events” guide is completely separate and unrelated.

Hope that was helpful.

Hi Mayjer,

I had already, but tried again, and still not working.

Double checked, as follow:

This is the address that I got from Ganache
image

And this is how my plugin is configured
image

You’re right. Edited.

Just to complement, I ran the Transfer transaction a few times from Remix.
And, of course, when I try to run the plugin, I have my frpc running.

Cheers,
Murilo

the other thing to check is the ABI. It should only be the object for the Transfer event:

  {
    "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"
      }
    ],
    "name": "Transfer",
    "type": "event"
  }

Will need to delete the plugin, save, then define again to change it.

Awsome!! ABI was the problem.

My bad, I was importing from a different contract :blush:

Thank you Mayjer

1 Like