Minting with Moralis.executeFunction on Node won't work

Hello everyone,

I have written the code below to mint NFTs using Moralis.executeFunction, but I am getting the error below.

C:\DriveD\Projects\object-to-NFT\node_modules\@ethersproject\logger\lib\index.js:233
        var error = new Error(message);
                    ^
Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.6.0)
  reason: 'could not detect network',
  code: 'NETWORK_ERROR',
  event: 'noNetwork'

Here is my code.

 const mintAndGo = async () => {
   // setUploading(true);
   
   await Moralis.start({
    moralisSecret: process.env.MORALIS_SECRET
  });

      await Moralis.enableWeb3({
      chainId: 0x4,  //for Rinkeby
      privateKey: process.env.RINKEBY_PRIVATE_KEY,
    })
   
    const minter = await Moralis.executeFunction({
      functionName: "mint",
      abi,
      contractAddress: "0xCdA50367a485eF74a43E2614A44aDFB47FC7E093",
      params: {
        cid,
        data: []
      }
    })

    console.log("Minter", minter)
  }

I just followed the samples that I found on the internet but I donโ€™t know why it keeps complaining that it cannot find the network.
Any clues?

If you are on a free plan, enableWeb3 with a private key wonโ€™t work due to speedy nodes being discontinued. You will need to use ethers.js or web3.js directly if thatโ€™s the case.

1 Like