Contract event not syncing from EventSync

ok, it should be easier where there isn’t a variable length array, can you paste the new contract address in this configuration?

so here is a new test contract where we tested the variable length array, there are 3 test functions we tested here
https://rinkeby.etherscan.io/address/0x01B9a582B192e4042834523A404be6bF9E6B463b

testEmit just emits 1,2,3, worked without issue
testEmit2 returns the struct Nft
testEmit3 returns a variable length array of struct Nft

both 2 and 3 did not pick up with eventsync
we don’t believe the issue is related to the variable length array but rather to the struct

ok, related to the struct, you could modify in the ABI (in the event sync interface) to have a different equivalent form, like removing the struct and using only parameters

changing the abi without changing the contract? can you give me an example.

=>


        {
          "internalType": "address",
          "name": "paymentMethod1",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "price1",
          "type": "uint256"
        },
        {
          "internalType": "address",
          "name": "paymentMethod2",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "price2",
          "type": "uint256"
        }

you can do something like this directly in a new invented ABI that you can use to sync events

can you get a working copy of the abi with test emit 2 in my previous comment? modifying inputs, and internal types has not done anything for me thus far. I’ve tried several variations of this and perhaps you may be able to point out my mistake.

from:

{
  "anonymous": false,
  "inputs": [
    {
      "components": [
        {
          "internalType": "enum TestList.NftTokenType",
          "name": "nftTokenType",
          "type": "uint8"
        },
        {
          "internalType": "address",
          "name": "nftTokenAddress",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "nftTokenId",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "nftNumTokens",
          "type": "uint256"
        }
      ],
      "indexed": false,
      "internalType": "struct TestList.Nft",
      "name": "nft",
      "type": "tuple"
    }
  ],
  "name": "TestEmit2",
  "type": "event"
}

=> To:

{
  "anonymous": false,
  "inputs": [
    {
      "components": [
        {
          "internalType": "uint8",
          "name": "nftTokenType",
          "type": "uint8"
        },
        {
          "internalType": "address",
          "name": "nftTokenAddress",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "nftTokenId",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "nftNumTokens",
          "type": "uint256"
        }
      ]
    }
  ],
  "name": "TestEmit2",
  "type": "event"
}

I need the topics for those 3 events:

testEmit just emits 1,2,3, worked without issue
testEmit2 returns the struct Nft
testEmit3 returns a variable length array of struct Nft

for testEmit2, I have tried the topics
TestEmit2(Nft)
and later on
TestEmit2(uint8,address,uint256,uint256)

it looks like Web3.utils.sha3('TestEmit2(uint8,address,uint256,uint256)') doesn’t give the right value for that topic that it should be: 0x33b0faabcc485e4d173ca94be91e075cb1d9b3a6fdfb96c1b061ab7ecf112bab

what is the original abi for TestEmit2?

As stated before:

{
    "anonymous": false,
    "inputs": [
      {
        "components": [
          {
            "internalType": "enum TestList.NftTokenType",
            "name": "nftTokenType",
            "type": "uint8"
          },
          {
            "internalType": "address",
            "name": "nftTokenAddress",
            "type": "address"
          },
          {
            "internalType": "uint256",
            "name": "nftTokenId",
            "type": "uint256"
          },
          {
            "internalType": "uint256",
            "name": "nftNumTokens",
            "type": "uint256"
          }
        ],
        "indexed": false,
        "internalType": "struct TestList.Nft",
        "name": "nft",
        "type": "tuple"
      }
    ],
    "name": "TestEmit2",
    "type": "event"
  }

taken directly from etherscan.


=>
Web3.utils.sha3('TestEmit2((uint8,address,uint256,uint256))') => 0x33b0faabcc485e4d173ca94be91e075cb1d9b3a6fdfb96c1b061ab7ecf112bab

this works fine for me:

topic: TestEmit2((uint8,address,uint256,uint256))
abi:

{
  "anonymous": false,
  "inputs": [
    {
      "internalType": "uint8",
      "name": "nftTokenType",
      "type": "uint8"
    },
    {
      "internalType": "address",
      "name": "nftTokenAddress",
      "type": "address"
    },
    {
      "internalType": "uint256",
      "name": "nftTokenId",
      "type": "uint256"
    },
    {
      "internalType": "uint256",
      "name": "nftNumTokens",
      "type": "uint256"
    }
  ],
  "name": "TestEmit2",
  "type": "event"
}

thanks for your time. We were able to get the simple TestEmit2 test working thanks to your example, however we cannot get TestEmit3 which includes a tuple of the TestEmit2 object working. I can’t figure out the required ABI nor break down the topic properly, if possible could you show us the required ABI and topic for a tuple, or show us where we can find the documentation for connecting that with Moralis? Thanks again.

Here is the generated ABI and Topic

{
    "anonymous": false,
    "inputs": [
      {
        "components": [
          {
            "internalType": "enum TestList.NftTokenType",
            "name": "nftTokenType",
            "type": "uint8"
          },
          {
            "internalType": "address",
            "name": "nftTokenAddress",
            "type": "address"
          },
          {
            "internalType": "uint256",
            "name": "nftTokenId",
            "type": "uint256"
          },
          {
            "internalType": "uint256",
            "name": "nftNumTokens",
            "type": "uint256"
          }
        ],
        "indexed": false,
        "internalType": "struct TestList.Nft[]",
        "name": "nfts",
        "type": "tuple[]"
      }
    ],
    "name": "TestEmit3",
    "type": "event"
  }

Topic: TestEmit3(Nft[])

We have got it working with Topic: TestEmit3((uint8,address,uint256,uint256)[])

and ABI:

{
  "anonymous": false,
  "inputs": [
    {
      "components": [
        {
          "internalType": "uint8",
          "name": "nftTokenType",
          "type": "uint8"
        },
        {
          "internalType": "address",
          "name": "nftTokenAddress",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "nftTokenId",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "nftNumTokens",
          "type": "uint256"
        }
      ],
      "name": "nfts",
      "type": "tuple[]"
    }
  ],
  "name": "TestEmit3",
  "type": "event"
}

nice!
how does Moralis handle that variable length part? as in if it has an array with 2 elements in an event and an array with 3 elements in another event

reads the array and its elements into a single column/field. can’t complain as long as it works!

I tried this same solution with Event streams API but it is not working for me.

The event topic contains a dynamic length array of struct

Topic I have used: ItemsEquipped(address,uint256,uint256[],(address,unit256,uint256)[])

what code gives that error? did you use the expected abi? what happens?

Yes, I am using the expected ABI and this error is being thrown while creating a stream