I've two contracts deployed one is UserRegistration and another is Exam

I've getUser(uint id) method to fetch data of particular user using users mapping,

function getUser(uint _id) public constant returns(uint,string,string,uint,uint) {

  User memory c = users[_id];


Now, I've another contract Exam in which I want to call getUser() function from UserRegistration contract so, I've done it like this,

pragma solidity 0.4.25;

contract UserRegistration
    function getUserCount() public returns(uint);
    function getUser(uint) public returns(uint,string,string,uint,uint);

contract Exam
    address private addrUsr;
    uint public count;
    UserRegistration r;
    constructor(address _addrUsr)
        r = UserRegistration(addrUsr);

    function updateCount() public {


    function getUserData(uint _id) public
        //WHAT to do HERE//;


But, how to parse the values returned by getUser() function into getUserData() so that if I call getUserData() function it should return all the values returned by getUser(), and as the values returned by getUser() function are of different data type I can't store them in an array.

Please help me

1 Answer 1


I noticed you're using constant in the registry. If that's right for the compiler you're using, stick with that, otherwise view for a newer compiler.

In any case, use it in both:

You should add view to the getter functions in both contracts.

function getUserData(uint _id) public view returns (uint,string,string,uint,uint) { // or constant
    //WHAT to do HERE//
    uint id;
    string name;
    string class;
    uint age;
    uint pincode;

    (id, name, class, age, pincode) = r.getUser(_id);

    return(id, name, class, age, pincode);

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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