-
-
Notifications
You must be signed in to change notification settings - Fork 111
/
LilENS.sol
36 lines (28 loc) · 1.11 KB
/
LilENS.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.10;
/// @title lil ens
/// @author Miguel Piedrafita
/// @notice A stupidly-simple namespace implementation.
contract LilENS {
/// ERRORS ///
/// @notice Thrown when trying to update a name you don't own
error Unauthorized();
/// @notice Thrown when trying to register a name that's already taken
error AlreadyRegistered();
/// @notice Stores the registered names and their addresses
/// @dev This automatically generates a getter for us!
mapping(string => address) public lookup;
/// @notice Registers a new name, and points it to your address
/// @param name The name to register
function register(string memory name) public payable {
if (lookup[name] != address(0)) revert AlreadyRegistered();
lookup[name] = msg.sender;
}
/// @notice Allows the owner of a name to point it to a different address
/// @param name The name to update
/// @param addr The new address this name should point to
function update(string memory name, address addr) public payable {
if (msg.sender != lookup[name]) revert Unauthorized();
lookup[name] = addr;
}
}