Solidity
您必須先部署並連結以下庫,然後才能部署新版本的 Contract
我製作了我的自定義庫並嘗試在我自己的項目中使用。
下面是 2_deploy_contracts.js
module.exports = async(deployer, netowrk) => { await deployer.deploy(OptionStorage, ownerAddress); await deployer.deploy(LDerivativeFactory); await deployer.link(LDerivativeFactory, DerivativeFactory); await deployer.deploy(DerivativeFactory, OptionStorage.address, XToken); };
在測試案例中,我試圖將其用作
beforeEach(async () => { optionStorage = await OptionStorage.new(owner); //library = await Library.new(); //DerivativeFactory.link('LDerivativeFactory',library.address); derivativeFactory = await DerivativeFactory.new(optionStorage.address, quoteToken.address, { from : owner, gas : 50000 }); });
但是在執行測試案例時,我遇到了錯誤
錯誤:DerivativeFactory 包含未解析的庫。您必須先部署並連結以下庫,然後才能部署新版本的 DerivativeFactory: LDerivativeFactory
如何解決?我也嘗試連結測試案例,然後我遇到了不同的錯誤
錯誤:錯誤:基本費用超過 gas 限制
任何幫助都是令人欽佩的
您應該使用問題 #501中推薦的修復程序,它導致的問題是松露的工件沒有按正確的順序更新。
async function doDeploy(deployer, network) { await deployer.deploy(OptionStorage, ownerAddress); await deployer.deploy(LDerivativeFactory); await deployer.link(LDerivativeFactory, DerivativeFactory); await deployer.deploy(DerivativeFactory, OptionStorage.address, XToken); } module.exports = (deployer, network) => { deployer.then(async () => { await doDeploy(deployer, network); }); };