Created
March 7, 2018 19:28
-
-
Save PillarDevelopment/4b64c6c879a9b341aa865e66996fa05f to your computer and use it in GitHub Desktop.
контракт реестра имен-имена вместо адресов
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
| contract Users { | |
| // Здесь хранятся имена. Отображение объявлено как открытое, чтобы | |
| // для него автоматически генерировалась функция-аксессор 'users', | |
| // которая принимает в качестве аргумента строку фиксированной длины. | |
| mapping (bytes32 => address) public users; | |
| // Регистрация предоставленного имени с адресом пользователя, | |
| // вызвавшего функцию. | |
| // Мы не хотим, чтобы пользователи регистрировались с пустым именем. | |
| function register(bytes32 name) { | |
| if(users[name] == 0 && name != ""){ | |
| users[name] = msg.sender; | |
| } | |
| } | |
| // Отмена регистрации имени с адресом пользователя. | |
| function unregister(bytes32 name) { | |
| if(users[name] != 0 && name != ""){ | |
| users[name] = 0x0; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment