Solidity
升級到 Solidity 版本 0.5.0 出現部署失敗錯誤,在 0.4.24 上完美部署了相同的智能合約
相同的智能合約在solidity 0.4.24 版本中執行順利,但現在當我更新solidity 版本並解決智能合約中的許多錯誤時,我打算將其部署在ganache-cli 中,現在出現以下錯誤。請注意,我在 deloy_all 文件下面有 4 個合同。
2_deploy_all.js
const Manager = artifacts.require("Manager"); const Delegate = artifacts.require("Delegate"); const Interface = artifacts.require("Interface"); const ExternalStorage = artifacts.require("ExternalStorage"); module.exports = function(deployer, network, accounts) { deployer .deploy( Delegate ) .then(function() { return deployer .deploy( Manager, Delegate.address ) .then(function() { return deployer .deploy( ExternalStorage ) .then(function() { return deployer .deploy( Interface, Manager.address, ExternalStorage.address ) }); }); }); };
錯誤
2_deploy_all.js =============== Error: *** Deployment Failed *** "Delegate" is an abstract contract or an interface and cannot be deployed. * Import abstractions into the '.sol' file that uses them instead of deploying them separately. * Contracts that inherit an abstraction must implement all its method signatures exactly. * A contract that only implements part of an inherited abstraction is also considered abstract. at Deployer._preFlightCheck (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-deployer/src/deployment.js:178:1) at <anonymous> at process._tickCallback (internal/process/next_tick.js:160:7) Truffle v5.0.1 (core: 5.0.1) Node v9.6.
注意:我嘗試從 Delegate 合同製作 IDelegate 合同並部署它,但結果是一樣的。
此時我需要幫助以在 0.5.0 版中部署我的所有智能合約
這是 Solidity 中的重大更改列表。https://solidity.readthedocs.io/en/v0.5.0/050-break-changes.html
您的合同必須編譯。正如@Data_Kid 所說,Remix 是解決問題的好地方。可能不會太多,但解決每個問題至關重要。
該錯誤表明您的
Delegate
合約可能無法部署。要麼是因為它interface
是合約而不是合約,要麼是因為它具有在任何情況下都不會部署的未定義函式。提到這一點是因為您可能正在處理多個問題並且很難確定。我的建議是在繼續 truffle 遷移之前使用 Remix(或 solc)進行乾淨的編譯。
希望能幫助到你。