Created
September 30, 2015 12:20
-
-
Save d11e9/d0c2febea162c1bf8ba5 to your computer and use it in GitHub Desktop.
Byteme.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract byteme { | |
struct Val { | |
bool hex; | |
bytes data; | |
} | |
mapping (bytes32 => Val) public data; | |
event Log(address indexed, string, bytes32 indexed, bytes); | |
function get (bytes32 key) constant returns (bytes){ | |
return data[key].data; | |
} | |
function isHex(bytes b) internal returns(bool) { | |
return b[0] == "0" && b[1] == "x"; | |
} | |
function set (bytes32 key, bytes value) returns(bool){ | |
bool h = isHex(value); | |
data[key] = Val( h, value); | |
Log(msg.sender, "Set key", key, value); | |
return h; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment