[SOLVED] Issues With Event Listeners On The Local Dev Chain

I have set up a local dev chain using hardhat, without any mainnet forking, using chainId: 31337.

I have a script that deploys a few contracts, and a separate script that calls those contracts to execute a few of our expected user flows.

I spun up a Moralis server and pointed it to my Local Dev Chain. Server URL: https://ud5f2waitqqg.usemoralis.com:2053/server.

I have frpc configured to point to the Moralis server, and in the Dashboard > View Details > Devchain Proxy Server interface I see a status of “Connected”

So far so good.

The issue comes when I try to create event listeners for any of my contracts. In the “Sync and Watch Contract Events” form I have ensured that my contract’s Topic, ABI, and Address are all correct. I also enabled historical syncing to make sure that once the event listener is created it will backfill everything that has occurred on my local hardhat network.

In order to avoid the issues outlined here (Sync events on local dev chain) where event listeners break if you stop and restart your hardhat network, my order of operations was:

  1. Start hardhat network
  2. Run contract-deploying and contract-function-calling scripts
  3. Spin up a totally new Moralis server
  4. Copy the frpc configs from the Moralis UI and paste them into my frpc.ini
  5. Start the frpc process
  6. Ensure the Moralis UI shows “Connected”
  7. Create the event listener via the “Sync and Watch Contract Events” form, then wait a few minutes

After all of that, there are 2 major issues:

  1. The table that was automatically created by Moralis when I created the event listener contains the following fields: objectId, updatedAt, createdAt, ACL instead of the fields outlined by my ABI (shown below).
  2. That table does not get populated with any events.

I have been fighting with this for several days so any help would be much appreciated :slight_smile:

Topic:
ChangeDaoNFTCloneCreated(address,address)

ABI:

{
  "anonymous": false,
  "inputs": [
    {
      "indexed": true,
      "internalType": "address",
      "name": "changeDaoNFTClone",
      "type": "address"
    },
    {
      "indexed": true,
      "internalType": "address",
      "name": "changeMaker",
      "type": "address"
    }
  ],
  "name": "ChangeDaoNFTCloneCreated",
  "type": "event"
}

I’ll try to look on server later to see if it is something obvious there

it doesn’t look like it is working, I don’t know what it is the problem.

can you try with ganache?

Hey @cryptokid thanks so much for the quick follow up :slight_smile:

So I did not have the local network running overnight. I have it up now, and using the same process, created a new server so that I could provide a new URL for us to look at while my local process was live.

Despite following the exact same procedure that failed before, this time it worked! Hooray!

So, I think we can consider this “resolved” insofar as it is working now, though I have no clue why previous identical attempts failed. Looks like I’ll just need to leave hardhat running locally for a while haha.

1 Like