0

I have a view function in my contract that takes an address as a parameter and returns a uint:

function getNumber(address _address) public view returns (uint) {
    require(_address != 0x0);
    return theList[_address].length;
}

In my App.js:

this.contracts.TheContract.methods.getNumber(this.state.account).call()

where:

this.state.account

is set in the constructor

Result:

Error: Invalid number of parameters for "getNumber". Got 42 expected 1

I tried converting to a byte array but that produces other errors.

Any Ideas?

Thanks

  • how do you initialize this.state.account? – mirg Mar 25 '18 at 17:24
  • constructor(props, context) { super(props) this.state = { account: props.accounts[0] } console.log("account = " + this.state.account) } – Phillip Gibb Mar 25 '18 at 18:24
  • not sure honestly. did you tried to cast at string (using toString())? It seems that is getting each char of the address as single parameter which is strange. – mirg Mar 26 '18 at 2:27
  • I am not sure what I between then and now, but it works now. – Phillip Gibb Mar 27 '18 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.