[SOLVED] Event is not logging in Moralis database on devchain

it looks like ie has that forking set there

Hmmm
Let me check it, after refining if it works or not
let me catch you back

Thanks btw

Hi Sir @cryptokid

I am in Woooooh condition
You saved me. :innocent:, you listened, you saved me
Thanks a lot :innocent: Praise to God

1 Like

@cryptokid
I’m also facing the same issue. I restart the Moralis server and hardhat local node as well. Still, I’m not seeing any events logged in the data base.

Server Url: https://xtqqb4chgkvl.usemoralis.com:2053/server

Can you please help?

I don’t see something wrong with that server now, I restarted the server now

I am facing the same issue with my moralis db
its not showing my events . I have tried creating new server but it still not updating my events

this is my sever URL:https://aewqzftsqjdz.usemoralis.com:2053/server

this is my addEvents.js

const Moralis = require("moralis-v1/node")
require("dotenv").config()
const contractAddresses = require("./constants/networkMapping.json")
let chainId = process.env.chainId || 31337
let moralisChainId = chainId == "31337" ? "1337" : chainId
const contractAddress = contractAddresses[chainId]["NftMarketplace"][0]

const serverUrl = process.env.NEXT_PUBLIC_SERVER_URL
const appId = process.env.NEXT_PUBLIC_APP_ID
const masterKey = process.env.masterKey

async function main() {
    await Moralis.start({ serverUrl, appId, masterKey })
    console.log(`Working with contarct address ${contractAddress}`)

    let itemListedOptions = {
        //Moralis understands a local chainas 1337
        chainId: moralisChainId,
        address: contractAddress,
        sync_historical: true,
        topic: "ItemListed(address,address,uint256,uint256)",
        abi: {
            anonymous: false,
            inputs: [
                {
                    indexed: true,
                    internalType: "address",
                    name: "seller",
                    type: "address",
                },
                {
                    indexed: true,
                    internalType: "address",
                    name: "nftAddress",
                    type: "address",
                },
                {
                    indexed: true,
                    internalType: "uint256",
                    name: "tokenId",
                    type: "uint256",
                },
                {
                    indexed: false,
                    internalType: "uint256",
                    name: "price",
                    type: "uint256",
                },
            ],
            name: "ItemListed",
            type: "event",
        },
        tableName: "ItemListed",
    }
    let itemBoughtOptions = {
        chainId: moralisChainId,
        address: contractAddress,
        sync_historical: true,
        topic: "ItemBought(address,address,uint256,uint256)",
        abi: {
            anonymous: false,
            inputs: [
                {
                    indexed: true,
                    internalType: "address",
                    name: "buyer",
                    type: "address",
                },
                {
                    indexed: true,
                    internalType: "address",
                    name: "nftAddress",
                    type: "address",
                },
                {
                    indexed: true,
                    internalType: "uint256",
                    name: "tokenId",
                    type: "uint256",
                },
                {
                    indexed: false,
                    internalType: "uint256",
                    name: "price",
                    type: "uint256",
                },
            ],
            name: "ItemBought",
            type: "event",
        },
        tableName: "ItemBought",
    }
    let itemCancledOptions = {
        chainId: moralisChainId,
        address: contractAddress,
        sync_historical: true,
        topic: "ItemCancled(address,address,uint256)",
        abi: {
            anonymous: false,
            inputs: [
                {
                    indexed: true,
                    internalType: "address",
                    name: "seller",
                    type: "address",
                },
                {
                    indexed: true,
                    internalType: "address",
                    name: "nftAddress",
                    type: "address",
                },
                {
                    indexed: true,
                    internalType: "uint256",
                    name: "tokenId",
                    type: "uint256",
                },
            ],
            name: "ItemCancled",
            type: "event",
        },
        tableName: "ItemCancled",
    }

    const listedResponse = await Moralis.Cloud.run("watchContractEvent", itemListedOptions, {
        useMasterKey: true,
    })
    const boughtResponse = await Moralis.Cloud.run("watchContractEvent", itemBoughtOptions, {
        useMasterKey: true,
    })
    const cancledResponse = await Moralis.Cloud.run("watchContractEvent", itemCancledOptions, {
        useMasterKey: true,
    })
    if (listedResponse.successs && cancledResponse.success && boughtResponse.success) {
        console.log("Success! database Updated with events")
    } else {
        console.log("Something went wrong")
    }
}

main()
    .then(() => process.exit(0))
    .catch((error) => {
        console.log(error)
        process.exit(1)
    })

it also doesn’t showing the success condition when creating events on moralis instead it showing else case on my console but it is listing them there after that when I am minting my nft it is not recording the event

@cyptokid can you help me asap

were you able to make it work?

No tried everything still events are not updating
my githubb links
frontEnd: https://github.com/ritesh798/Next-js-Hardhat-NFT-Marketplace-frontend
backend: https://github.com/ritesh798/Hardhat-Nft-Marketplace
.

you could try it on a testnet instead of a local devchain

it should work, we just made it work on another server, double check the contract address and for chain id set “0x539” when you add the event sync

now my code is giving me a new error says "Master Key required for this request " I haven’t changed anything just changed the server and its credentials. I have updated my code with the new server

strange, it is the master key from the same account/server?
is masterKey sent as parameter to moralis.start ?

it now working in my older dapp . things that worked for me is that I changed my chain Id to 0x539
and also I changed table names in the sync script . when I am using the older tables names which were previously synced it is still not working. so change the table names. thanks for your constant support . I hope it helps many developers.

1 Like

I’m having the same problem as everyone, my server url is https://fblvionstdcx.usemoralis.com:2053/server

Any idea whats wrong here…

"synch_hitorical":true

it looks like a typo here

Thank you help and for pointing out the mistake. It seems it’s still not working …

it could be something else now

are you sure this is the correct contract address?

0x5FbDB2315678afecb367f032d93F642f64180aa3

yes, it is the right one…