我正试图找出以下代码的问题所在,因为它确实在混合中成功地部署了。
pragma solidity ^0.5.11;
contract MyContract {
// Storage
address contractOwner;
address[] userFilesList;
mapping ( string => address ) private accountAddressesByProfile;
address[] public accountList;
bytes16[] accountTypes;
mapping(bytes16 => bool) accountTypesMap;
constructor() public {
contractOwner = msg.sender;
bytes16[5] memory initialAccountTypes = [
bytes16("Account1"),
bytes16("Account2"),
bytes16("Account3"),
bytes16("Account4"),
bytes16("Account5")
];
for (uint8 i = 0; i < initialAccountTypes.length; i++ ) {
bytes16 accountType = initialAccountTypes[i];
accountTypes.push(accountType);
accountTypesMap[accountType] = true;
}
}
}
问题是,当指向远程节点(在我的例子中,是运行Azure验证权威联盟的奇偶节点)时,它拒绝从混合节点进行部署。
当我试图在混合Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? "message" must be a nonempty string
上部署时,我会得到以下错误
无论如何,当我部署时,错误0x0 Transaction mined but execution failed
会失败。
但是,如果我将语用版本更改为0.4.26
,它就会成功部署。我试图了解正在发生的事情,或者看看在构造函数中实现循环是否是一个好的实践。
发布于 2019-12-10 10:35:22
当您更改契约(通常添加新方法)但未能将契约部署到网络时,就会发生这种情况。
在我的例子中,我没有这样做,因为松露。truffle migrate
没有部署新的契约代码,您必须显式地告诉块菌通过truffle migrate --all
部署新合同。
我的猜测是,Remix试图为添加的新方法发送消息,但在网络上先前部署的契约代码中找不到新方法。
编辑:我也得到了同样的错误,当我有太少的气体调用的方法,修复后,如上所述。
发布于 2021-11-01 00:11:25
将气体限制设置为9000000...should帮助。
发布于 2019-11-06 09:06:23
我不知道你在部署什么,比如'Javascript VM‘或'injected web3 3’,但是也许使用'injected web3‘可以解决您的问题,或者如果您已经在使用它,那么就转到元询问并尝试重新设置您的帐户。
这帮助我摆脱了这个错误,但我不确定这是否是正确的解决方案。
注意:新来的!如有任何建议,将不胜感激!
https://ethereum.stackexchange.com/questions/77253
复制相似问题