Access multiple return values (a, b, c) from solidity function in web3js

0 votes

I have a function that returns multiple values. I wish to access these from Web3js.

function testReturnBet(uint index) constant returns (address player, 
                                                     uint tokensPlaced, 
                                                     uint8[4] numbers,
                                                     uint ratioIndex,
                                                     uint timestamp,
                                                     uint rollIndex,
                                                     uint winAmount) {
        bet outBet = bets[index];
        return (outBet.player,
                outBet.tokensPlaced, 
                outBet.numbers, 
                outBet.ratioIndex, 
                outBet.timestamp, 
                outBet.rollIndex, 
                outBet.winAmount);
    }
Sep 14, 2018 in Blockchain by digger
• 26,550 points
332 views

1 answer to this question.

0 votes

You'll get an array of return values with 7 values (0-6). The third one should be an array with 4 values.

In the Truffle style, it would look something like:

contract.testReturnBet(index).then(function(response) {
  console.log(response); // should be an array
});
answered Sep 14, 2018 by slayer
• 29,170 points

Related Questions In Blockchain

+1 vote
2 answers

How to return value from a chaincode in Hyperledger Fabric?

Hyperledger Fabric supports only 2 types of ...READ MORE

answered Jun 13, 2018 in Blockchain by Perry
• 17,020 points
919 views
0 votes
1 answer
0 votes
1 answer

Solidity: How can I return a list of user-defined function?

You can do it with something like ...READ MORE

answered Sep 26, 2018 in Blockchain by digger
• 26,550 points
64 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
169 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,550 points
4,301 views
0 votes
1 answer
+1 vote
2 answers
0 votes
1 answer

How to get return value from solidity contract?

Once you call a constant function, you ...READ MORE

answered Aug 16, 2018 in Blockchain by slayer
• 29,170 points
568 views