Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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);
    }
like image 865
RFV Avatar asked Aug 30 '26 17:08

RFV


1 Answers

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
});
like image 140
Rob Hitchens Avatar answered Sep 04 '26 01:09

Rob Hitchens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!