New answers tagged

0

You have to individually get the bytes from bytes32. Each byte represents two numbers from hex value. You can individually map the numbers from hex value to corresponding char value in the ASCII table. An example implementation is demonstrated below. function bytes32ToLiteralString(bytes32 data) public pure returns (string memory result) { ...


0

Issue was that I was converting from cpp serialized std::string message which contains a LEB128 encoded length prefix, thus needed to add back for deserialization: // "SPDX-License-Identifier: UNLICENSED" pragma solidity ^0.8.0; contract strings { function string_tobytes(string memory s) public pure returns (bytes memory){ bytes ...


0

See OpenZeppelin's ERC165Checker, which looks like what you need.


0

Use inline assembly : function parseMsgData() public view returns (bytes32 _address){ bytes32 _address; assembly { calldatacopy(0x0, 4, 36) _address := mload(0x0) } return _address; } Basically what I am doing here is, I am parsing the msg.data from byte4 to byte36 to get the first input parameter. Each input parameter is of 32 bytes. If ...


Top 50 recent answers are included