Blockchain 我想将结构的数组从固定改为动态,就像我从数组编译器中删除参数时抛出的错误一样
pragma坚实度^0.4.17 合同签署{Blockchain 我想将结构的数组从固定改为动态,就像我从数组编译器中删除参数时抛出的错误一样,blockchain,ethereum,solidity,smartcontracts,go-ethereum,Blockchain,Ethereum,Solidity,Smartcontracts,Go Ethereum,pragma坚实度^0.4.17 合同签署{ struct signature { string value; uint rate; address sender_acc; } signature[5] public unverified_sig; // struct array is fixed but I want dynamic, if i del 5 then it //give
struct signature {
string value;
uint rate;
address sender_acc;
}
signature[5] public unverified_sig; // struct array is fixed but I want dynamic, if i del 5 then it
//gives error mentioned in the end
function add_signature(string rec_signature) public {
unverified_sig[0].sender_acc=msg.sender;
unverified_sig[0].value=rec_signature;
unverified_sig[0].rate=0;
}
}
输出错误:
transact-to-Signature.add_签名错误:VM错误:操作码无效。执行可能引发的操作码无效。调试事务以获取更多信息
您使用哪种版本的Solidity?我用混音的
0.5.0
编译。struct的动态数组没有任何问题。但有一个警告是,该功能的燃气成本过高,将超过燃气限值
函数Storage.add_签名的气体需求是无限的:如果
函数的气体要求高于块气体极限,则
无法执行。请避免在函数或操作中出现循环
修改大面积存储(包括清除或复制)
存储中的阵列)
pragma坚实度^0.4.17;