在映射内部返回结构字段的问题

时间:2019-04-07 11:05:30

标签: ethereum solidity smartcontracts

我有上面的代码

   mapping(string => Owner) public Owners;

    function addOwner( string memory name, string memory surname, string memory fathername, string memory mothername, string memory ethnicityId, string memory id) public returns(int8)
    {
        Owner memory owner;
        owner.name = name;
        owner.surname = surname;
        owner.fathername = fathername;
        owner.mothername = mothername;
        owner.ethnicityId = ethnicityId;
        owner.id = id;

        Owners[id] = owner;
        return 0;
    }

    function getOwnerName(string memory id) public returns(string memory, string memory) {
        Owner storage owner = Owners[id];
        return (owner.name, owner.surname);
    }


我正在插入具有addOwner的Owner,并尝试使用getOwnerName进行检索,但是Ringeby网络未返回我插入的数据。当我在remix IDE上使用javascript VM时,该函数返回正确的数据

0 个答案:

没有答案