Moralis Web3 API not in Cloud Functions?

Hi all!

I’m trying to work with web3 in a cloud function. I’m aware that I can do things like:

const web3 = Moralis.web3ByChain("0x38"); // BSC
const abi = Moralis.Web3.abis.erc20;
const address = "0x...."

// create contract instance
const contract = new web3.eth.Contract(abi, address);

// get contract name
const name = await contract.methods
  .name()
  .call()
  .catch(() => "");

In the cloud function, but I’m wondering if I can do something like:

Moralis.Cloud.define("updateNFTImages", async (request) => {
    await Moralis.Web3API.token.getERC721Metadata({ address, chain }))

So far, I’m getting an error saying it doesn’t recognize token so I’m assuming at the moment this functionality doesn’t exist.

Hi Patrick,

I just tested and for me it worked to use Web3API in a cloud function after I upgraded to latest Moralis Server (0.0.263).

1 Like

I just had to update my Moralis server version. Thank you!