Truffle-Migration

導致此錯誤的原因:嘗試執行呼叫合約函式的交易,但收件人地址不是合約地址

  • November 10, 2018

我有一份契約和一套摩卡咖啡測試。我最近從使用 truffle 附帶的乙太坊客戶端(執行時獲得的客戶端truffle develop)切換到ganache-cli. 不知何故,在它們之間來回切換時,我導致我的測試無法執行,並且遷移似乎也不起作用。當我連接到 ganache 時,遷移工作,但不是松露開發客戶端。這是完整的錯誤消息。

$ truffle migrate --reset
Using network 'development'.

Running migration: 1_initial_migration.js
 Replacing Migrations...
 ... 0x9391ac92dfbf86306e9ed896e7f9d5d45d9d88a072323ca1ef116f242ae0d2be
 Migrations: 0x8cdaf0cd259887258bc13a92c0a6da92698644c0
Saving successful migration to network...
 ... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Attempting to run transaction which calls a contract function, but recipient address 0x8f0483125fcb9aaaefa9209d8e9d7b9c8b9fb90f is not a contract address
   at Object.InvalidResponse (/home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1)
   at /home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:86:1
   at /home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/truffle-migrate/index.js:225:1
   at /home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1
   at XMLHttpRequest.request.onreadystatechange (/home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
   at XMLHttpRequestEventTarget.dispatchEvent (/home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
   at XMLHttpRequest._setReadyState (/home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
   at XMLHttpRequest._onHttpResponseEnd (/home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
   at IncomingMessage.<anonymous> (/home/altair/.nvm/versions/node/v9.6.1/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1)
   at IncomingMessage.emit (events.js:132:15)
   at endReadableNT (_stream_readable.js:1101:12)
   at process._tickCallback (internal/process/next_tick.js:152:19)

我可以找到很多關於“遇到錯誤,保釋。網路狀態未知。手動查看成功的交易”的問題和 SE 問題。但在那之後的那一行總是和我的不一樣。我似乎找不到任何 google 搜尋結果"Attempting to run transaction which calls a contract function, but recipient address" is not a contract address

該消息對我來說很有意義,但那怎麼可能不是契約地址呢?

ETA:我也從 truffle 升級4.0.5到 truffle 4.1.0,這可能是導致問題的原因。

正如上面Mavlarnivicaa.json的評論中所提供的,答案是刪除build/contracts/. 然後下一次執行truffle migrate不再失敗。

我剛剛使用了 migrate –reset (不刪除/build),並且工作

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