Created
March 6, 2017 22:38
-
-
Save LefterisJP/d3e012e5b9e8b594e532e43b44e327b6 to your computer and use it in GitHub Desktop.
NameRegistry.sol
This file contains hidden or 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
pragma solidity ^0.4.4; | |
contract NameRegistry { | |
mapping (address => bytes32) public addr_to_string; | |
mapping (bytes32 => address) public string_to_addr; | |
event NameRegistered(address a, bytes32 name); | |
function NameRegistry () { | |
} | |
function register (bytes32 name) { | |
if (string_to_addr[name] != 0x0) { | |
throw; | |
} | |
string_to_addr[name] = msg.sender; | |
addr_to_string[msg.sender] = name; | |
NameRegistered(msg.sender, name); | |
} | |
function name_for(address addr) returns (bytes32) { | |
return addr_to_string[msg.sender]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment