1

I'm building a web interface for my dapp, but can't seem to retrieve individual struct items from a public array.

I'm trying to retrieve a Proposal struct from the proposals() public function in my contract (I have a Proposal[] public proposals; array).

So the user enters a particular proposalID and they should be returned the Proposal struct. The method works fine on Remix.

However, I'm getting this alert:

error BigNumber Error: new BigNumber() not a base 16 number

I've verified the ABI is correct when I initialize my JS myContract object.

What's causing this error? Here's the code that's resulting in an error:

            myContract.proposals(propID, function(error, result) {
                if(!error) {
                    alert("Result: " + result);
                } else {
                    alert("There was a problem: " + error);
                }
            });

All the other functions work (ie. myContract.owner etc).

3
  • 1
    Looks like one can't return a struct for anything other than internal use...need to make an accessor method that returns the relevant parts. Commented Aug 23, 2017 at 3:17
  • You got it right. You can't return a public struct (at least not now, maybe in future). Commented Aug 23, 2017 at 7:54
  • Similar question here: ethereum.stackexchange.com/questions/7317/…
    – Stan James
    Commented Oct 6, 2017 at 18:25

1 Answer 1

1

Looks like one can't return a struct for anything other than internal use...

Instead, make an accessor method that returns the relevant parts of the struct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.