I've the following contract function:
/*Solidity Code, inside my contract*/
function isGranted(address _user, address _content) view external returns (bool) {
return (grantedAccess[_user][_content]);
}
That works on Remix IDE without any problem.
Then I wrote a Web3JS frontend
this.catalog = (this.web3.eth.contract(this.props.catalog.abi)).at(this.props.catalog.address);
this.catalog.isGranted(
this.web3.eth.defaultAccount, //Parameter1
this.state.address, //Parameter2
(err, res) => { //Callback
if(!err){
console.log(res);
this.setState(this.setState({userHasRightAccess: res}));
} else {
console.error(err);
}
})
But the execution returns Error: Invalid number of arguments to Solidity function
. I tried to add the other optional parameter to Web3js function but the error remains. Any idea/solution?
(I don't use Truffle or any more framework. Web3JS version is "0.19.0")
Edit: I've update the library to 0.20.6 version
Best Answer
The problem was that an argument was
undefined
. I'll added a check and now works