如何从数组结构中获得一个可靠的值?

时间:2019-05-14 11:30:50

标签: ethereum solidity truffle

我想获取Solidity中struct内部的值, 但我不知道如何获得它。

pragma solidity >=0.4.21 <0.6.0;
contract PlaceList {

    struct hoge {
    uint id;
    address user;
  }

  hoge[] public hoges;

  constructor() public {
    admin = msg.sender;
  }

  function set(uint id) public {
    hoges.push(hoge(id, msg.sender));
  } 

  function getId() public view returns(uint) {
    return (hoges[0].id);
  } 
}

当我呼叫getId时,控制台命令会这样说,

ƒ () {
              if (abiItemModel.isOfType('constructor')) {
                return target.executeMethod(abiItemModel, arguments, 'contract-deployment');
              }

              return targe…

请问我有什么建议可以通过使用Solidity函数获得id吗?

0 个答案:

没有答案