current position:Home>Bytes32tostring doesn't work. Ask the boss for help

Bytes32tostring doesn't work. Ask the boss for help

2022-02-04 00:07:53 Q & A of Denglian community

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);    }}

https://www.bilibili.com/video/BV1St411a7Pk?t=41&p=16

This one of mine is the same as that in the tutorial , course bytes32Tostring It works ,

My has been reporting this mistake , I don't understand what this error report means , Ask for advice 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)




Take the answer 1:

INVALID ARGUMENT: Illegal parameters , You should pass in one 32 Parameters of bytes

Put parameters :0x7a68 become :0x7a68000000000000000000000000000000000000000000000000000000000000

except 0x After a total of 64 position =32 Bytes






Other answers 1:

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202040007511599.html

Random recommended