I am currently working on a NFT marketplace project where i am connecting to my local running hardhat blockchain with my Moralis server. I have done everything to connect it and it is also showing connected on dashboard. I wants to listen some events from my block chain but after running a script that just list an NFT on marketplace, it is not showing anything on my Moralis dashboard. I have synced my events with Moralis and have provided everything correctly, but still not showing anything on the database.
here is an image of my Moralis database where last 4 enteries are my table that i synced with moralis server:
My code that i used to sync my blockchain events with my server:
const Moralis = require("moralis/node");
const dotenv = require("dotenv");
dotenv.config();
const serverUrl = process.env.NEXT_PUBLIC_SERVER_URL;
const appId = process.env.NEXT_PUBLIC_APP_ID;
const masterKey = process.env.masterKey;
const chainId = process.env.chainId || 31337;
const moralisChianId = chainId == "31337" ? "1337" : chainId;
const contractAddresses = require("./constants/address.json");
async function main() {
await Moralis.start({ serverUrl, appId, masterKey });
const contractAddressesArray = contractAddresses[chainId]["NFTMarketplace"];
console.log(contractAddressesArray);
const address =
contractAddresses[chainId]["NFTMarketplace"][
contractAddressesArray.length - 1
];
console.log(address);
let listItemsOptions = {
chainId: moralisChianId,
sync_historical: true,
topic: "ItemListed(address,uint256,uint256,address)",
address: address,
abi: {
type: "event",
anonymous: false,
name: "ItemListed",
inputs: [
{ type: "address", name: "nftAddress", indexed: true },
{ type: "uint256", name: "tokenId", indexed: true },
{ type: "uint256", name: "price", indexed: true },
{ type: "address", name: "seller", indexed: false },
],
},
tableName: "ItemListed",
};
let buyItemsOptions = {
chainId: moralisChianId,
sync_historical: true,
topic: "ItemBought(address,address,uint256,uint256)",
address: address,
abi: {
type: "event",
anonymous: false,
name: "ItemBought",
inputs: [
{ type: "address", name: "seller", indexed: true },
{ type: "address", name: "buyer", indexed: true },
{ type: "uint256", name: "tokenId", indexed: false },
{ type: "uint256", name: "price", indexed: true },
],
},
tableName: "ItemBought",
};
let updateItemsOptions = {
chainId: moralisChianId,
sync_historical: true,
topic: "ItemUpdated(address,uint256,uint256,address)",
address: address,
abi: {
type: "event",
anonymous: false,
name: "ItemUpdated",
inputs: [
{ type: "address", name: "nftAddress", indexed: true },
{ type: "uint256", name: "newPrice", indexed: true },
{ type: "uint256", name: "tokenId", indexed: true },
{ type: "address", name: "seller", indexed: false },
],
},
tableName: "ItemUpdated",
};
console.log(moralisChianId);
let removeItemsOptions = {
chainId: moralisChianId,
sync_historical: true,
topic: "ItemRemoved(address,uint256,address)",
address: address,
abi: {
type: "event",
anonymous: false,
name: "ItemRemoved",
inputs: [
{ type: "address", name: "nftAddress", indexed: true },
{ type: "uint256", name: "tokenId", indexed: true },
{ type: "address", name: "seller", indexed: true },
],
},
tableName: "ItemRemoved",
};
const listResponse = await Moralis.Cloud.run(
"watchContractEvent",
listItemsOptions,
{
useMasterKey: true,
}
);
const buyResponse = await Moralis.Cloud.run(
"watchContractEvent",
buyItemsOptions,
{
useMasterKey: true,
}
);
const removeResponse = await Moralis.Cloud.run(
"watchContractEvent",
removeItemsOptions,
{
useMasterKey: true,
}
);
const updateResponse = await Moralis.Cloud.run(
"watchContractEvent",
updateItemsOptions,
{
useMasterKey: true,
}
);
if (listResponse && buyResponse && removeResponse && updateResponse) {
console.log("database updated with watching events");
} else {
console.log("Something went wrong...");
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.log(error);
process.exit(1);
});
Sharing image showing perfect connection of my local dev chain with moralis server:
 I am not able to find the problem with my setup
please help