How to get call contract from job cloud function?

Hi, this is my code

    const contract = new web3.eth.Contract(abi, address);
const heroes = await contract.methods
        .getListHeroesOf('0xc40F66275bFA7c4A052e1ec09F082da84C41b13B')
        .call()
        .catch((err) => {
            const logger1 = Moralis.Cloud.getLogger();
          logger1.info(err.code);
        });

and my abi

[{
        "inputs": [
            {
                "internalType": "address",
                "name": "owner",
                "type": "address"
            }
        ],
        "name": "getListHeroesOf",
        "outputs": [
            {
                "components": [
                    {
                        "components": [
                            {
                                "internalType": "uint256",
                                "name": "heroId",
                                "type": "uint256"
                            },
                            {
                                "internalType": "uint256",
                                "name": "types",
                                "type": "uint256"
                            },
                            {
                                "internalType": "string",
                                "name": "name",
                                "type": "string"
                            },
                            {
                                "internalType": "uint8",
                                "name": "rarity",
                                "type": "uint8"
                            },
                            {
                                "internalType": "uint8",
                                "name": "level",
                                "type": "uint8"
                            },
                            {
                                "internalType": "uint256",
                                "name": "experience",
                                "type": "uint256"
                            },
                            {
                                "internalType": "uint256",
                                "name": "lastBattleTime",
                                "type": "uint256"
                            }
                        ],
                        "internalType": "struct Hero",
                        "name": "hero",
                        "type": "tuple"
                    },
                    {
                        "internalType": "uint256",
                        "name": "price",
                        "type": "uint256"
                    }
                ],
                "internalType": "struct HeroOnSales[]",
                "name": "",
                "type": "tuple[]"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    }]

the logger return : BUFFER_OVERRUN

Please help me. I don’t know where I’am wrong.

what is the contract address that you used in new web3.eth.Contract(abi, address)?
also, how did you initialise web3 in that could function?

This worked for me:

Moralis.Cloud.define("get_heroes", async (request) => {
  const abi = [{
        "inputs": [
            {
                "internalType": "address",
                "name": "owner",
                "type": "address"
            }
        ],
        "name": "getListHeroesOf",
        "outputs": [
            {
                "components": [
                    {
                        "components": [
                            {
                                "internalType": "uint256",
                                "name": "heroId",
                                "type": "uint256"
                            },
                            {
                                "internalType": "uint256",
                                "name": "types",
                                "type": "uint256"
                            },
                            {
                                "internalType": "string",
                                "name": "name",
                                "type": "string"
                            },
                            {
                                "internalType": "uint8",
                                "name": "rarity",
                                "type": "uint8"
                            },
                            {
                                "internalType": "uint8",
                                "name": "level",
                                "type": "uint8"
                            },
                            {
                                "internalType": "uint256",
                                "name": "experience",
                                "type": "uint256"
                            },
                            {
                                "internalType": "uint256",
                                "name": "lastBattleTime",
                                "type": "uint256"
                            }
                        ],
                        "internalType": "struct Hero",
                        "name": "hero",
                        "type": "tuple"
                    },
                    {
                        "internalType": "uint256",
                        "name": "price",
                        "type": "uint256"
                    }
                ],
                "internalType": "struct HeroOnSales[]",
                "name": "",
                "type": "tuple[]"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    }]
  const web3 = Moralis.web3ByChain('0x38')
  const contract = new web3.eth.Contract(abi, '0xc40F66275bFA7c4A052e1ec09F082da84C41b13B');
  const heroes = await contract.methods
        .getListHeroesOf('0xCD5426D90C0E8020a35C322Bc226Fc2e2B6C6677')
        .call()
        .catch((err) => {
            const logger1 = Moralis.Cloud.getLogger();
          logger1.info(JSON.stringify(err));
        });
  return heroes;
});