我想发送一个序列号或字母,如“aa5glegd...”对于44字节作为uint256来调用方法,并在该方法中将其更改为字节,然后将字节转换为uint256。但是互联网上的很多方法都是针对bytes32的。
发布于 2018-11-24 15:48:00
使用程序集
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
https://stackoverflow.com/questions/49231267
复制相似问题