0

每当我尝试读取任何视图函数时,使用 angular 和moralis 都会出现此错误。下面是返回错误的函数

async contractBalance() {
    let options = {
      contractAddress: CONTRACT_ADDRESS,
      functionName: "investorCount",
      abi: ABI
    }
await Moralis.enableWeb3();
return await Moralis.executeFunction(options);}

下面是我的 abi 和函数的链接

https://www.dropbox.com/s/cpbne99coinerm2/abi.ts?dl=0

https://www.dropbox.com/scl/fi/sp26mrdpllghc6de63w9k/Document.docx?dl=0&rlkey=9fjrpc9s91wldbuq8mahdfuae

4

1 回答 1

0

你确定investorCount格式正确吗?

它应该看起来像这样。

const ABI = [
 {
    inputs: [],
    name: "message",
    outputs: [
      {
        internalType: "string",
        name: "",
        type: "string",
      },
    ],
    stateMutability: "view",
    type: "function",
  },
  {
    inputs: [
      {
        internalType: "string",
        name: "_newMessage",
        type: "string",
      },
    ],
    name: "setMessage",
    outputs: [],
    stateMutability: "nonpayable",
    type: "function",
  }
];

const readOptions = {
  contractAddress: "0xe...56",
  functionName: "message",
  abi: ABI
};

const message = await Moralis.executeFunction(readOptions);
console.log(message)
// -> "Hello World"
于 2022-02-14T09:35:44.707 回答