Is there a workaround to convert a bytes memory to uint256?
Solidity – Conversion from Bytes Memory to Uint Explained
contract-developmentsoliditytruffle-compile
Related Topic
- [Ethereum] Solidity convert hex string to bytes
- Solidity Data Conversion – Solidity Data Type Conversion from Bytes to Address/String/Uint/Int: Any Library Available?
- Fixing Invalid Implicit Conversion Errors from uint256 to bytes in Solidity
- Solidity Conversion – Convert Bytes Memory to Address Type in Solidity
- Solidity – 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