I'm having problems with Error: Invalid number of arguments to Solidity function. Basically, the problem comes when I call sendTransaction with an event handler. i.e. here's the code after hooking up a Solidity event:

// premisObject was setup earlier to point at the Abi at the contract's deployed address const premisObject = this.premisObject // rightsSetRights has been hooked up to the required event const rightsSetRights = this.rightsSetRights rightsSetRights.watch(function (error, result) { if (!error) { const index = result.args._index const hash = result.args._hash premisObject._setRights(hash,index, {gas: 200000})) } else { console.error(result) } })

That call to premisObject._setRights(hash,index, {gas: 200000})) fires the error. If I make the same call outside of the event handler:

premisObject._setRights(this.state.hash, 0, {gas: 200000})

....works just fine. I need to call premisObject._setRights inside that event handler, somehow, because that's when I know the value of the required index. Any ideas what's going on? Or perhaps you've got a cunning plan which means I can circumvent the issue?

  • Did you check your parameters index, hash and premisObject are correct? Also I think some parameters my need a '0x' in front. Also if premisObject is a contract it doesn't seems like a good idea to have a public method name starting with _. – Ismael Jun 15 '17 at 3:25
  • Yup, all checked, and all seem correct. I'm currently circumventing the problem by redesigning my dAapp by generating the required index, rather than getting it from the event handler. – glowkeeper Jun 15 '17 at 10:29
  • ps. it isn't _setRights - it's setRights (that was a transcription error) ;) – glowkeeper Jun 15 '17 at 11:14

I never got to the bottom of this - I ended up redesigning my dApp so that I set, rather than get, the index.

| improve this answer | |

Your Answer

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

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