我收到了一些与bytes32相关的错误。我试着用铸造法,但这并不能解决问题。我的代码是:
pragma solidity ^0.5.6.0;
contract peInKSub{
bytes32 [] m_pendingIndex ;
struct pendingConfirmation{
bytes32 index;
uint yetNeeded;
bytes32 pendingOp;
}
pendingConfirmation pending;
function confirmAndCheck ( bytes32 _operation )public returns ( bool ) {
pending.pendingOp = m_pendingIndex [ _operation ];
// if we 're not yet working on this operation ,
// switch over and reset the confirmation status .
if ( pending . yetNeeded == 0) {
pending . index = m_pendingIndex[_operation] . length ++;
//m_pendingIndex [ pending . index ] = _operation ;
}//if
}//fun
}//contract我的错误消息是:
solc prg46.solprg46.sol:14:38: Error:类型bytes32不能隐式转换为预期类型uint256。pending.pendingOp = m_pendingIndex _操作;^待决。索引= m_pendingIndex_操作 .长度++;^待决。索引= m_pendingIndex_操作 .长度++;^- uint8待决。索引= m_pendingIndex_操作 .长度++;^
谁来指点我。
祖尔菲。
发布于 2021-03-26 15:20:52
m_pendingIndex[_operation] . length ++该变量是bytes32,如下所定义:
bytes32 [] m_pendingIndex ; 因此,它有32个字节长,长度不能进行调整。你似乎在试图增加它,但这是不可能的。
希望能帮上忙。
发布于 2022-12-26 17:45:04
看起来,您正在转换长度,这是bytes32的uint。您试过用abi.encodePacked()包装长度操作吗?
https://ethereum.stackexchange.com/questions/95247
复制相似问题