Is there a workaround to convert a bytes memory to uint256?
[Ethereum] Solidity: Conversion bytes memory to uint
contract-developmentsoliditytruffle-compile
Related Topic
- [Ethereum] Solidity convert hex string to bytes
- [Ethereum] Solidity: data type conversion from bytes to address/string/uint/int [ any library available? ]
- [Ethereum] Invalid implicit conversion from uint256 to bytes memory requested
- [Ethereum] Can anyone explain how bytes memory can be converted to address type in solidity
- [Ethereum] Converting bytes memory to bytes calldata
Best Answer
It's possible but there's no easy way to do it. You either have to do some bitwise xor and shifting to build the uint, or use inline assembly to
mload
.Here's the working code, feel free to copy paste