10

bytes32Tostring 不起作用的,求大佬帮忙看下 | 登链社区 | 技术问答

 3 years ago
source link: https://learnblockchain.cn/question/1911
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
bytes32Tostring 不起作用的,求大佬帮忙看下

5 bytes32Tostring 不起作用的,求大佬帮忙看下

回答问题即可获得 5 经验值,回答被采纳后即可获得 10 学分。
pragma solidity ^0.4.26;

contract Bytes32ToString{
    
    bytes2 name=0x7a68;
    
    function changeIt() returns(string){
        
    //    return string(name);  
    
    }
    
    
    function bytes32Tostring(bytes32 _newname) view returns(string){
        
        bytes memory newname = new bytes(_newname.length);
        
        for(uint i = 0;i<_newname.length;i++){
            
            newname[i] = _newname[i];
            
        }
        
        return string(newname);
        
        
    }
    
    
  
}

我的这个和教程上是一样的,教程 bytes32Tostring 是起作用的,

我的一直在报这个错,不明白这个报错是表达什么意思,求教
image.png

call to Bytes32ToString.bytes32Tostring errored: Error encoding arguments: Error: incorrect data length (argument=null, value="0x7a68", code=INVALID_ARGUMENT, version=abi/5.0.7)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK