【转载】solidity智能合约[12]-固定字节数组相互转换


#1

固定字节数组相互转换

固定长度字节数组之间能够进行相互转换

pragma solidity ^0.4.23;

contract  fixTofix{

      bytes6 name =  0x6a6f6e736f6e;

    //bytes1: 0x6a
    function  Tobytes1() view public returns(bytes1){
        return bytes1(name);
    }
            //bytes2: 0x6a6f
       function  Tobytes2() view public returns(bytes2){
        return bytes2(name);
    }
    // bytes8: 0x6a6f6e736f6e0000
    function  Tobytes3() view public returns(bytes8){
        return bytes8(name);
    }

}
  • 本文链接: <https ://dreamerjonson.com/2018/11/19/solidity-12-fixByteConvertion/>