【发布时间】:2018-11-02 20:14:53
【问题描述】:
我正在使用 truffle 部署合约,当我将 gas limit 指定为我想用于交易的 gas 时,我总是会收到超出 gas limit 的错误。为什么会这样?
编辑 我想要做的是将加密小猫 KittyCore.sol 合约部署到我的本地 devnet。我正在使用松露来部署它。
从另一个页面How to deploy truffle contract to dev network when using inheritance?,我发现由于有一个合约层次结构,我需要按顺序部署我的合约。我使用了这种技术,我能够部署 7 个合约中的 4 个,其中第五个是 KittyAuction,出现以下错误:无法存储合约代码,请检查您的 gas 量
下面发布的是我的松露部署脚本
var KittyCore = artifacts.require("KittyCore");
var KittyMinting = artifacts.require("KittyMinting");
var KittyAuction = artifacts.require("KittyAuction");
var KittyBreeding = artifacts.require("KittyBreeding");
var KittyOwnership = artifacts.require("KittyOwnership");
var KittyBase = artifacts.require("KittyBase");
var KittyAccessControl = artifacts.require("KittyAccessControl");
var SaleClockAuction = artifacts.require("SaleClockAuction");
module.exports = function (deployer) {
deployer.deploy(KittyAccessControl).then(function () {
return deployer.deploy(KittyBase).then(function () {
return deployer.deploy(KittyOwnership).then(function () {
return deployer.deploy(KittyBreeding).then(function () {
return deployer.deploy(KittyAuction, {
gas: 400000
}).then(function () {
return deployer.deploy(KittyMinting).then(function () {
return deployer.deploy(KittyCore);
})
})
})
})
})
});
};
我的gas limit设置为18000000000。这个gas数是通过在实际部署失败的合约上运行以下函数产生的
var gasPrice;
KittyAuction.web3.eth.getGasPrice(function (error, result) {
gasPrice = Number(result);
console.log(gasPrice);
})
我一直在摆弄这个数字,但似乎没有任何效果。
【问题讨论】:
-
你可以设置的最小gas限制是多少,并且交易仍然成功?
-
另外,编辑您的问题以包括您的合同代码、您指定的 gas 限制以及您是如何得出该数字的。
-
我正在尝试将 cryptokitties 主合约部署到我的本地 devnet。有很多引用要发布,但它是免费提供的,除了将支付关键字添加到构造函数之外,我没有做任何更改