[SOLVED] Contract event not syncing from EventSync With Enum Parameter

Hello,

I have an event with the ABI below:

{
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "bytes32",
          "name": "_affiliateId",
          "type": "bytes32"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "_numberOfTokens",
          "type": "uint256"
        },
        {
          "indexed": false,
          "internalType": "enum SalientYachtsSYONE_v02.NFTType",
          "name": "_nftType",
          "type": "uint8"
        }
      ],
      "name": "AffiliateSale",
      "type": "event"
    }

I created an event sync for it using the inputs below:
Topic: AffiliateSale(bytes32,uint256,uint8)
Abi: same as above
Address: 0xcef1bFc0b864193278a66bFDdC99EdE58C66E319
Table Name: AffiliateSales

However, the table is empty and does not have any of the 3 columns I am expecting to see: _affiliateId, _numberOfTokens, _nftType

I saw in other topics the recommendation to use the “type” of the parameter “unit8” instead of using the enum nam “NFTType” and that is what I did but it still does not work.

I can see the events on snowtrace: https://testnet.snowtrace.io/address/0xcef1bfc0b864193278a66bfddc99ede58c66e319#events

You can filter on topic: 0x2f5905fac4ad4af88ee4d477308761cefd638cdc30e994adf1bb77f84d02ec30

I also see the following in the Moralis server logs:

2022-02-10T22:24:55.583Z - Ran cloud function coreservices_addEventSync for user undefined with:
  Input: {"chainId":"0xa869","address":"0xcef1bFc0b864193278a66bFDdC99EdE58C66E319","tableName":"AffiliateSalesTwo","topic":"AffiliateSale(bytes32,uint256,uint8)","abi":{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"affiliateId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"numberOfTokens","type":"uint256"},{"indexed":false,"internalType":"enum SalientYachtsSYONE_v02.NFTType","name":"nftType","type":"uint8"}],"name":"AffiliateSale","type":"event"},"filter":"","sync_historical":true,"description":"Affiliate Sales Two"}
  Result: {"status":200,"data":{"success":true,"result":true}}

Thanks in advance for your time.

The use of _ in names does not work.

https://docs.moralis.io/moralis-server/automatic-transaction-sync/smart-contract-events

1 Like

Thanks @denivros - do I have to remove the “_” from the contract itself? I tried creating another event sync with the ABI below but I am still getting an empty table:

{
  "anonymous": false,
  "inputs": [
    {
      "indexed": true,
      "internalType": "bytes32",
      "name": "affiliateId",
      "type": "bytes32"
    },
    {
      "indexed": false,
      "internalType": "uint256",
      "name": "numberOfTokens",
      "type": "uint256"
    },
    {
      "indexed": false,
      "internalType": "enum SalientYachtsSYONE_v02.NFTType",
      "name": "nftType",
      "type": "uint8"
    }
  ],
  "name": "AffiliateSale",
  "type": "event"
}

I basically removed the “_” from all name attributes.

That, I don’t know but guess it doesn’t hurt trying if it’s not a lot of work?
I’m also have issues with the event syncing and I have a similar server log…

you only need to remove it from the abi, you don’t have to change the contract

Thanks @cryptokid, I did that but I am still not getting any events synced. I used the ABI below:

{
  "anonymous": false,
  "inputs": [
    {
      "indexed": true,
      "internalType": "bytes32",
      "name": "affiliateId",
      "type": "bytes32"
    },
    {
      "indexed": false,
      "internalType": "uint256",
      "name": "numberOfTokens",
      "type": "uint256"
    },
    {
      "indexed": false,
      "internalType": "uint8",
      "name": "nftType",
      "type": "uint8"
    }
  ],
  "name": "AffiliateSale",
  "type": "event"
}

I removed the “_” from all name attributes and changed the internalType of nftType to uint8 - saw this in another topic on the forum for a similar issue.

I also tried with the original ABI minus the “_”, that did not work either, Please see the ABI below:

{
  "anonymous": false,
  "inputs": [
    {
      "indexed": true,
      "internalType": "bytes32",
      "name": "affiliateId",
      "type": "bytes32"
    },
    {
      "indexed": false,
      "internalType": "uint256",
      "name": "numberOfTokens",
      "type": "uint256"
    },
    {
      "indexed": false,
      "internalType": "enum SalientYachtsSYONE_v02.NFTType",
      "name": "nftType",
      "type": "uint8"
    }
  ],
  "name": "AffiliateSale",
  "type": "event"
}

can you paste your server url? I’ll probably look tomorrow

Hi @cryptokid here is the server URL:

https://ebo1jcglqjiw.usemoralis.com:2053/server

Thanks for your help with this.

it works now, you should remove the invalid event that was added with _

Thanks a lot @cryptokid, much appreciated. I removed the invalid event sync.

1 Like

@cryptokid what did you do to make it work? I’m having issues with event syncing as well…

Rarible clone events not syncing

in that particular case I restarted coreservices and it was an event with invalid column names, you can try to update the server (it should also restart coreservices)

when using ganache, it is better to start a new server

Thanks for the response! I’ve tried that multiple times with no success…

you can create another thread where you also add the server url

@cryptokid Hi cryptokid, I believe I have the same problem with TokenMinted events not syncing into my database. The contract address is: 0xDA02e06fC55701784D7D4D504dEd7bd95D64Bb4A. My server url is: https://gbpmt7ieb117.usemoralis.com:2053/server. I think the coreservices might need to be restarted as well? Thank you!

I will take a look a little later

Thank you so much! Please let me know if there is anything else you want me to provide you.

the issue in this particular case is because the abi has names that start with _, you have to remove that _ from names in abi:

instead of "name":"_from" it should be "name":"from"

OMG. I works now…thank you for your help!

1 Like