pragma solidity ^0.4.18; contract Expression { mapping( address => uint[] ) internal userMessages; function sendMessage(uint _message) external { userMessages[msg.sender].push(_message); } function bytes32ToString(bytes32 x) constant returns (string) { bytes memory bytesString = new bytes(32); uint charCount = 0; for (uint j = 0; j < 32; j++) { byte char = byte(bytes32(uint(x) * 2 ** (8 * j))); if (char != 0) { bytesString[charCount] = char; charCount++; } } bytes memory bytesStringTrimmed = new bytes(charCount); for (j = 0; j < charCount; j++) { bytesStringTrimmed[j] = bytesString[j]; } return string(bytesStringTrimmed); } function getMessageByOwner(address _add) public view returns(uint[]) { return userMessages[_add]; } function getMyMessage() public view returns(uint[]) { return userMessages[msg.sender]; } function test(bytes32 _test) external view returns(string){ return bytes32ToString(_test); } }
0.4.18