【发布时间】:2021-07-19 11:31:54
【问题描述】:
我尝试使用 Remix 将合约部署到测试网(所有测试网都返回相同的消息),但出现此错误:
Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
Internal JSON-RPC error. { "code": -32000, "message": "gas required exceeds allowance (30000000) or always failing transaction" }
但是当我尝试在 BSC 主网中部署它时,一切正常,没有错误。有什么建议吗?
这是相关代码
contract artemis is Context, IERC20, Ownable {
// ...
constructor() public {
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router =
IUniswapV2Router02(0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F);
// Create a Pancakeswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
//exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
// ...
}
我在这里上传整个代码,因为它太长了。
【问题讨论】:
-
请编辑您的问题并分享您的合约源代码。 “事务总是失败”是错误消息中更可能的原因。
标签: solidity smartcontracts remix