I have a contract deployed on the blockchain that returns multiple values.
contract Test{
function getAandB( uint x )returns ( uint a, uint b ){
uint y = x * 2 ;
return ( x , y )
}
}
The question is how do I access both returning values when calling the contract externally from web3?
var ( a , b ) = myContractInstance.getAandB( x );
gives me an error
var value = myContractInstance.getAandB( x );
console.log ( value.a )
comes back as undefined
Best Answer
With new Destructuring assignment syntax you can do this in one line:
Output is as expected: