[SOLVED] Dumb question warning - is accessing cloud functions over REST api a speedy node?

Hi!

I call cloud functions over a REST api, for example the below:

https://laeartv72t0b.usemoralis.com:2053/server/functions/getHomeMessages

This has started returning ā€œuser blockedā€. I see posts on here related to the deprecation of speedy nodes, but I donā€™t think this call is to a speedy node (?), and the moralis docs still say it should work (https://docs.moralis.io/moralis-dapp/cloud-code/cloud-functions#call-via-rest-api).

Has anyone else seen this?

Thanks!

It depends on what that cloud function does. The cloud function works, it returns a message. Now if the cloud function was using the speedy nodes then it can return that error from speedy nodes.

Hiya! Thanks for the quick reply. I donā€™t used speedy nodes anywhere in my cloud functions.

Thatā€™s interesting, you say that function works for you? I just get ā€œuser blockedā€, both on using that link in a browser and through my app.

This is what I see, thanks again @cryptokid!

{ā€œcodeā€:141,ā€œerrorā€:ā€œInvalid JSON RPC response: ā€œuser blockedā€ā€}

What is the code for that function?

Itā€™s not all that pretty :sweat_smile:

I have other cloud functions that also return the same error.

// ************************************************************
// ***                  GET HOME MESSAGES                   ***
// ************************************************************
Moralis.Cloud.define("getHomeMessages", async (request) => {
  const BTDMDABI = 
  [
    {
      "inputs": [],
      "name": "totalFees",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "account",
          "type": "address"
        }
      ],
      "name": "balanceOf",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
  ]
    
  const results = [];
  const web3      = Moralis.web3ByChain(CHAIN_ID); // BSC
  const contract  = new web3.eth.Contract(BTDMDABI, BITDIAMOND_TOKEN_ADDRESS);
  var   distro    = await (contract.methods.totalFees().call())/(10**8);
  const totalDistro = (distro.toFixed(0)).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");

  var troveBalance = await (contract.methods.balanceOf(TROVE_WALLET_ADDRESS).call())/(10**8);
  const totalTroveBalance = (troveBalance.toFixed(0)).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
 
  var bountyBalance = await (web3.eth.getBalance(BOUNTY_TOKEN_ADDRESS))/(10**18);
  const totalBountyBalance = (bountyBalance.toFixed(4)).toString();

  var wordsBalance = await (contract.methods.balanceOf(WORD_WALLET_ADDRESS).call())/(10**8);
  const totalWordsBalance = (wordsBalance.toFixed(0)).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");;

  const queryAllTime = new Moralis.Query("BscNFTOwners");
  queryAllTime.equalTo("token_address", TREASURE_TOKEN_ADDRESS.toLowerCase());
  const queryResultsAllTime = await queryAllTime.count() + 5; 
  const totalTreasureNFTs = (queryResultsAllTime.toFixed(0)).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
  
  BTDMDPrice = await Moralis.Cloud.run("getPrice")
  
  var weekdayString=new Array(7);
  weekdayString[1]="Monday";
  weekdayString[2]="Tuesday";
  weekdayString[3]="Wednesday";
  weekdayString[4]="Thursday";
  weekdayString[5]="Friday";
  weekdayString[6]="Saturday";
  weekdayString[0]="Sunday";

  var monthString=new Array(12);
  monthString[0]="January";
  monthString[1]="February";
  monthString[2]="March";
  monthString[3]="April";
  monthString[4]="May";
  monthString[5]="June";
  monthString[6]="July";
  monthString[7]="August";
  monthString[8]="September";
  monthString[9]="October";
  monthString[10]="November";
  monthString[11]="December";

  var rightNow = new Date();
  var day = weekdayString[rightNow.getUTCDay()]
  var date = rightNow.getUTCDate();
  var month = monthString[rightNow.getUTCMonth()];
  var year = rightNow.getUTCFullYear();
  var hours = rightNow.getUTCHours();
  var minutes = rightNow.getUTCMinutes();
  var seconds = rightNow.getUTCSeconds();
  if (minutes < 10)
  {
    minuteString = "0" + minutes;  
  }
  else
  {
    minuteString = "" + minutes;
  }

  if (seconds < 10)
  {
    secondString = "0" + seconds;  
  }
  else
  {
    secondString = "" + seconds;
  }

  results.push({
    "HEADER": "Platform Stats",
    "LINE": "on " + day + " " + date + " " + month + " " + year + " @ " + hours + ":" + minuteString + ":" + secondString + " UTC",
  });
  results.push({
    "HEADER": "",
    "LINE": "",
  });
  results.push({
    "HEADER": totalDistro,
    "LINE": "BTDMD Distributed to Holders using our passive yield mechanism",
  });
  results.push({
    "HEADER": "",
    "LINE": "",
  });
  results.push({
    "HEADER": "1 BTDMD = ",
    "LINE": BTDMDPrice,
  });
  results.push({
    "HEADER": "",
    "LINE": "",
  });
  results.push({
    "HEADER": totalTreasureNFTs,
    "LINE": "Treasure NFTs minted",
  });
  results.push({
    "HEADER": "",
    "LINE": "",
  });
  results.push({
    "HEADER": totalTroveBalance,
    "LINE": "BTDMD to be won in the Trove!",
  });
  results.push({
    "HEADER": "",
    "LINE": "",
  });
  results.push({
    "HEADER": totalBountyBalance,
    "LINE": "BNB in the Bounty Prize Pool!!",
  });
  results.push({
    "HEADER": "",
    "LINE": "",
  });
  results.push({
    "HEADER": totalWordsBalance,
    "LINE": "BTDMD to be won in Words of Power game!!!",
  });
  return results;
});

This is where it uses speedy nodes. You have to use a custom RPC url now

You can also use runContractFunction for read only functions

Aha! Thank you so much! :smiley:

Wahoo, custom RPC up and running, back in business.

Thank you again @cryptokid!!

1 Like