如何使用 ABI 获取结构内部的数组

问题描述 投票:0回答:0

我无法在 User 结构中获取 weeklyBusiness 数组。因为合同已经部署,有没有办法我可以更改 ABI 以获取用户结构的所有组件,包括使用 userInfo 函数的数组。

struct WeeklyBusiness {
   uint256 amount;
   uint256 time;
}

struct User {
   uint256 level;
   uint256 start;
   WeeklyBusiness[] weeklyBusiness;
   uint256[3] registered;
}

mapping(address => User) public userInfo;

生成的 ABI:

{
      "inputs": [
        {
          "internalType": "address",
          "name": "",
          "type": "address"
        }
      ],
      "name": "userInfo",
      "outputs": [
        {
          "internalType": "uint256",
          "name": "level",
          "type": "uint256"
        },
        {
          "internalType": "uint256",
          "name": "start",
          "type": "uint256"
        }
      ],
      "stateMutability": "view",
      "type": "function"
}

我尝试将其添加到生成的 ABI 的输出中,但没有成功:

{
      "internalType": "tuple[]",
      "name": "weeklyBusiness",
      "type": "tuple[]"
}
javascript solidity web3js ethers.js hardhat
© www.soinside.com 2019 - 2024. All rights reserved.