成员“推”在地址[3]内存中与参数有关查找后找不到或看不到
我得到错误
Member "push" not found or not visible after argument-dependent lookup in address[3] memory.
函数,在此错误中,
function initiateTransaction( address payable _to, uint _amount ) public onlyUser returns(uint txnId) {
transaction memory newTxn;
newTxn.id = ++txnCount;
newTxn.amount = _amount;
newTxn.to = _to;
newTxn.initiatedBy = msg.sender;
newTxn.signedBy.push(msg.sender); // I'm getting error here.
}
我已经定义了结构如下
struct transaction {
uint id;
uint amount;
address payable to;
address initiatedBy;
address[3] signedBy;
}
I'm getting error
Member "push" not found or not visible after argument-dependent lookup in address[3] memory.
function in which I'm getting this error is
function initiateTransaction( address payable _to, uint _amount ) public onlyUser returns(uint txnId) {
transaction memory newTxn;
newTxn.id = ++txnCount;
newTxn.amount = _amount;
newTxn.to = _to;
newTxn.initiatedBy = msg.sender;
newTxn.signedBy.push(msg.sender); // I'm getting error here.
}
I've defined the struct as follows
struct transaction {
uint id;
uint amount;
address payable to;
address initiatedBy;
address[3] signedBy;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
签名
是一个固定大小的数组,因此您无法使用push()
来调整它大小。您需要跟踪数组中有多少个非零值并重写正确的项目。 (或动态计算索引,但在气体成本方面的优化程度较低。)
signedBy
is a fixed-size array, so you cannot resize it by usingpush()
.You need to keep track of how many non-zero values are in the array and rewrite the correct item. (Or calculate the index dynamically, but that would be less optimized in terms of gas costs.)