[SOLVED] Can't run Moralis Execute Function

Hi,

I tried to run the Moralis Execute Function and it always works well. However, today I ran into an error that said “Network Error”. I am not sure what happened. My code looks like the below:

const Moralis = require("moralis/node");
await Moralis.start({serverUrl,appId,moralisSecret});
let options4 = {
 contractAddress:'0x987ed22a5d80673093ea89258100af593ef31608',
  functionName: "ownerOf",
  abi: abiOwnerOf,
  params: { tokenId: '219' },
};
NFTs = await Moralis.executeFunction(options4);

And here is the error I get:

reason: ‘could not detect network’,
code: ‘NETWORK_ERROR’,
event: ‘noNetwork’

Is this because the Moralis Execute Function has changed?

Thanks.

Is that code complete? Because you would also need to use enableWeb3 in order to use executeFunction. This error is likely due to speedy nodes being shut down.

In your case, you can use runContractFunction since ownerOf is read only - alternatively if you don’t need to make transactions, you can use 2.0 SDK (for runContractFunction).

If you do need to make transactions from a Node.js script/app, you can use ethers.js directly.

Thank you so much. I want to make transactions but how to use ether.js with Moralis? Or do I need to run it through other providers?

Thanks

There is this way of using ethers.js that comes with Moralis (moralis-v1) and then you use the ethers.js methods of connecting to a provider and making transactions.

Otherwise you can install and use ethers.js directly.

You will need to use an RPC URL when setting up the provider - you can use a node provider like Chainstack.

Thank you very much for your help!