[SOLVED] Why is the Cloud Functions Call Via REST API no longer available? What's the substitution?

Why is the Cloud Functions Call Via REST API no longer available? What’s the substitution?

Here’s the old version of the documentation:

https://v1docs.moralis.io/moralis-dapp/cloud-code/cloud-functions#call-via-rest-api

Here is the actual calling URL:

https://xxx.usemoralis.com:2053/server/functions/getLandInfoById/?_ApplicationId=xxxxx&landId=106

The result is as follows:

{"code":141,"error":"Invalid JSON RPC response:  \"Speedy Nodes are discontinued, please move to API or our partner nodes. Read more here:  https://github.com/MoralisWeb3/changelog/blob/main/2022-07-11-speedy-node-removal.md\""}

How to solve it?

This looks like an error from the cloud code when it executes. Speedy nodes were discontinued in case that you are still using them in cloud code.

You can test with a simpler cloud function to see if it works to call it.

How to fix it? Is there documentation to help?

"error":"Invalid JSON RPC response: \"Speedy Nodes are discontinued, please move to API or our partner nodes.

Maybe you changed the way the contract functions are called

This is the exception Cloud Functions content

...
const contract = new web3.eth.Contract(Life_Map_ABI, mapAdd);
const result = await contract.methods.getParams().call();
return result;

I’ll try runContractFunction to see if I can solve this

you will need to use a custom RPC url if you want to use that syntax, runContractFunction should also work

runContractFunction It can be called successfully

A new question arises, how do you embed ‘runContractFunction’ into Cloud Functions?

not sure what you mean with embedding it, you can call it with web3api without issues

Is it OK to use this way?

Moralis.Cloud.httpRequest({
  url:'https://deep-index.moralis.io/api/v2/XXXXX'
})

you can call it this way too, you have to provide all the parameters

you can also use directly Moralis.Web3api. syntax in cloud code too

I’ve learned

I think it’s an RPC node ‘Speedy Node’ problem

Just redefine it

The code is roughly as follows:

// const web3 = Moralis.web3ByChain(chainId); 
//The default is
//https://speedy-nodes-nyc.moralis.io/YOUR_ID_HERE/bsc/mainnet
//But it's no longer working

  const web3 = new Moralis.Web3(
    new Moralis.Web3.providers.HttpProvider(speedyNodes)    
  );

Reference

Yes, you will have to use a different RPC url there instead of speedy node url