Could you upgrade the programme for me?

There is no NEXT_PUBLIC_SERVER_URL and master key from now on, since Moralis changed:
I want to upgrade the code but have no idea, can someone help me, thanks.

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 contrat address ${contractAddress}`)

let itemListedOptions = {
    // Moralis understands a local chain is 1337
    chainId: moralisChainId,
    sync_historical: true,
    topic: "ItemListed(address,address,uint256,uint256)",
    address: contractAddress,

const listedResponse = await"watchContractEvent", itemListedOptions, {
useMasterKey: true,

you are using la local devchain?

if that is the case than you can read this forum post that may help you:

Appreciate your reply, but I am using goerli testnet. Let me check this information if I can resolve it myself: ‘You will have to use streams api for events, there is a plugin for that for parse server in our documentation.’.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.