首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >bytes32不是隐式可兑换的

bytes32不是隐式可兑换的
EN

Ethereum用户
提问于 2021-03-26 14:33:26
回答 2查看 287关注 0票数 0

我收到了一些与bytes32相关的错误。我试着用铸造法,但这并不能解决问题。我的代码是:

代码语言:javascript
复制
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_操作 .长度++;^

谁来指点我。

祖尔菲。

EN

回答 2

Ethereum用户

发布于 2021-03-26 15:20:52

代码语言:javascript
复制
m_pendingIndex[_operation] . length ++

该变量是bytes32,如下所定义:

代码语言:javascript
复制
bytes32 [] m_pendingIndex ; 

因此,它有32个字节长,长度不能进行调整。你似乎在试图增加它,但这是不可能的。

希望能帮上忙。

票数 0
EN

Ethereum用户

发布于 2022-12-26 17:45:04

看起来,您正在转换长度,这是bytes32的uint。您试过用abi.encodePacked()包装长度操作吗?

票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/95247

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档