0

have this code:

struct UserScore {
    address user;
    uint score;
    uint time;
}
function getWithStruct(UserScore _user) public view returns (address, uint, uint) {
    return (_user.user, _user.score, _user.time);
}

It seems that metamask does not support this feature at the moment. But is there a workaround? It is necessary for me that users with metamask could transfer the signed data in the form of structure. What I can do for it?

0

You can archive this simply by using mapping and return from struct mapping values like this no need of ABIEncoderV2 :

code:

struct UserScore {
    address user;
    uint score;
    uint time;
}
mapping(address=>UserScore) public userscore;

function addUserScore(address _user, uint _score, uint _time)public returns (bool success){
    userscore[msg.sender] = UserScore(_user,_score,_time);
    return true;
}
function getWithStruct(address _userAdress) public view returns (address, uint, uint) {
    return (userscore[_userAdress].user, userscore[_userAdress].score, userscore[_userAdress].time);
}

Hope this will help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.