Ganache

address.transfer 在 ganache 中失敗

  • October 26, 2018

我正在從已部署的契約之一中呼叫 address.transfer() 。雖然,這適用於 remix(JavaScript VM 環境),但如果我在“ganache”上部署和執行相同的契約,同樣會失敗。

我得到以下關於使用 ganache 的堆棧,

Error: VM Exception while processing transaction: revert
   at \node_modules\web3-provider-engine\subproviders\provider.js:19:36
   at XMLHttpRequest.request.onreadystatechange (\node_modules\truffle-hdwallet-provider\node_modules\web3\lib\web3\httpprovider.js:118:13)
   at XMLHttpRequestEventTarget.dispatchEvent (\node_modules\xhr2\lib\xhr2.js:64:18)
   at XMLHttpRequest._setReadyState (\node_modules\xhr2\lib\xhr2.js:354:12)
   at XMLHttpRequest._onHttpResponseEnd (\node_modules\xhr2\lib\xhr2.js:509:12)
   at IncomingMessage.<anonymous> (\node_modules\xhr2\lib\xhr2.js:469:24)
   at emitNone (events.js:111:20)
   at IncomingMessage.emit (events.js:208:7)
   at endReadableNT (_stream_readable.js:1064:12)
   at _combinedTickCallback (internal/process/next_tick.js:138:11)
   at process._tickCallback (internal/process/next_tick.js:180:9)

我也嘗試在契約中設置“gas”,但這也無濟於事

你是如何呼叫你的合約方法的?當合約方法沒有被正確呼叫時,就會發生這種情況。

我在評論後得到了最大的讚許。https://github.com/trufflesuite/truffle/issues/748

另一個例子:

myContractInstance.myStateChangingMethod('someParam1', 'anotherParam', {from: someAddress, gas: 3000000});

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