我想发送一个序列号或字母,如“aa5glegd ....”,44字节作为uint256调用方法,并在该方法中将其更改为字节,然后将字节转换为uint256。但在互联网上有这么多的方法是bytes32
答案 0 :(得分:0)
使用程序集
function toBytes(uint256 x) returns (bytes b) {
b = new bytes(32);
assembly { mstore(add(b, 32), x) }
}
在此处找到了参考-https://ethereum.stackexchange.com/questions/4170/how-to-convert-a-uint-to-bytes-in-solidity