Go-Ethereum

從事件處理程序中呼叫 sendTransaction 時出現問題

  • June 18, 2017

我遇到了問題Error: Invalid number of arguments to Solidity function。基本上,當我使用事件處理程序呼叫 sendTransaction 時,問題就出現了。即這是連接 Solidity 事件後的程式碼:

// 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) } })

該呼叫會premisObject._setRights(hash,index, {gas: 200000}))觸發錯誤。如果我在事件處理程序之外進行相同的呼叫:

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

….工作得很好。我需要以premisObject._setRights某種方式在該事件處理程序內部呼叫,因為那時我知道所需索引的值。有什麼想法嗎?或者也許你有一個狡猾的計劃,這意味著我可以繞過這個問題?

我從來沒有深究這一點——我最終重新設計了我的 dApp,以便我設置而不是獲取索引。

引用自:https://ethereum.stackexchange.com/questions/17990