[SOLVED] Contract event sync cloud function but doesn’t sync in the DB

hi @cryptokid,

I have working on watch contract event using ‘watchContractEvent’ cloud function.

Cloud function run successfully and get response ‘true’, but table not created in moralis database.

cloud functioin.

Moralis.Cloud.define('createSyncTable', async (request) => {

let options = {
    chainId: request.params.chainId,
    address: request.params.address,
    topic: request.params.topic,
    abi: {},
    limit: 500000,
    tableName: request.params.tableName,
    sync_historical: false,
  };
  return Moralis.Cloud.run('watchContractEvent', options, {
    useMasterKey: true,
  });

});

hi @cryptokid,

manfully syncs with same ABI is work and generate tables but when i run cloud function then its get response {success: true} but table not sync in database

please help me sort out this issue.

what is the topic, abi, server url, table name on that server, chain

hi @cryptokid

Topic : Token721Created(address,address,uint256)
server url : https://a9ujwr1lleqk.usemoralis.com:2053/server
table name : CreatedfivefiveAVAXToken
chian : Avax

ABI

[
  {
    "anonymous": false,
    "inputs": [
      {
        "indexed": true,
        "internalType": "address",
        "name": "nftContract",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "address",
        "name": "owner",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "chainid",
        "type": "uint256"
      }
    ],
    "name": "Token1155Created",
    "type": "event"
  },
  {
    "inputs": [
      {
        "internalType": "string",
        "name": "name_",
        "type": "string"
      },
      {
        "internalType": "string",
        "name": "symbol_",
        "type": "string"
      }
    ],
    "name": "deployNewERC1155Token",
    "outputs": [
      {
        "internalType": "address",
        "name": "",
        "type": "address"
      }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  }
]

this is an abi with 2 entries?

did it work previously on that server to add an event sync?
I don’t see any event sync on that server, I also don’t see chains enabled for that server.

You can try first to enable chains for that server, or disable and enable again.

yes previously on this server its working but now its not working.

ok i will check

hi @cryptokid,

I have check in moralis network tabs and its already enable chains. please check below screenshot.

try to disable them and enable them again

hi @cryptokid,

I have already do that but not found any solution.

i have also try in different server but same issue found.

server URL : https://8ekxbyf8f89q.usemoralis.com:2053/server

I can see events added on this new server, a lot of events, if one of those events has issues like an invalid abi then everything will stop working

this server doesn’t work because it is an event with an invalid abi:
I can see this error:

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: Invalid ABI, The ABI must be of type event

hi @cryptokid

Thanks for support.

I have also see below error in logs like every event sync using cloud function ‘truncated’ word added , why this happen ?

You can ignore it. I think Truncated here mean that the entire ABI is not shown in the logs due to its length.

hi @cryptokid @johnversus

We have done using same ABI and same cloud function in new server.

Thanks for your support

1 Like