Accessing multiple return values (a, b, c) from hardness function in web3js
I have a function that returns multiple values. I want to access them 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);
}
+3
RFVenter
source
to share
1 answer
You will get an array of return values with 7 values (0-6). The third should be an array with 4 values.
In truffle style, it looks something like this:
contract.testReturnBet(index).then(function(response) {
console.log(response); // should be an array
});
+4
Rob hitchens
source
to share