0

solidity function:

function getCredentials(uint id) public constant returns(string,string,uint) 
{
    address ad=acadr[id];
    uemail=email[ad];
    ulocation=location[ad];
    ugid=gid[ad];
    return (uemail,ulocation,ugid);
}

web3 calling code:

myInstance.getCredentials(1,function (error, result) {
                             if (!error) {
                                 console.log(result);
                             } else
                                 console.log(error);
}

this prints a hexadecimal value in log instead of string and int

please help !

Shawn Tabrizi
  • 8,008
  • 4
  • 19
  • 38

2 Answers2

1

your function is updating the values of veriables so it will be considered as transactional function and a transaction will be generated for it in blockchain,

And what you will get in return of the call is transaction hash (transaction id) of that transaction,

So 2 options here

  1. Write a constant function to get the values of variables

  2. use events, kind of logging mechanism in solidity, which will return the values passes to it after the successful mining of your transaction.

For using events have a look at code in this question

SwapnilKumbhar
  • 763
  • 1
  • 11
  • 31
0

Use .call to send it as a read only call instead of a transaction.

myInstance.getCredentials.call(1, (error, result) => {

})
Miguel Mota
  • 5,143
  • 29
  • 47