Skip to content

Instantly share code, notes, and snippets.

@d11e9
Created September 30, 2015 12:20
Show Gist options
  • Save d11e9/d0c2febea162c1bf8ba5 to your computer and use it in GitHub Desktop.
Save d11e9/d0c2febea162c1bf8ba5 to your computer and use it in GitHub Desktop.
Byteme.sol
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