-
Notifications
You must be signed in to change notification settings - Fork 0
/
B0.sol
44 lines (37 loc) · 1.41 KB
/
B0.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
37
38
39
40
41
42
43
44
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract BionicOwlsEns {
mapping(address => string) public addresses;
mapping(string => address) public names;
mapping(string => address) public creators;
mapping(address => bool) public nameCreationStatus;
function createName(string memory name) public {
require(names[name] == address(0), "Name already exists");
require(!nameCreationStatus[msg.sender], "You have already created a name");
creators[name] = msg.sender;
names[name] = msg.sender;
addresses[msg.sender] = name;
nameCreationStatus[msg.sender] = true;
}
function transferName(string memory name, address newOwner) public {
require(names[name] == msg.sender, "You don't own this name");
names[name] = newOwner;
addresses[newOwner] = name;
addresses[msg.sender] = "";
nameCreationStatus[msg.sender] = false;
nameCreationStatus[newOwner] = true;
}
function deleteName(string memory name) public {
require(names[name] == msg.sender, "You don't own this name");
addresses[msg.sender] = "";
delete names[name];
delete creators[name];
nameCreationStatus[msg.sender] = false;
}
function getCreator(string memory name) public view returns (address) {
return creators[name];
}
function getOwner(string memory name) public view returns (address) {
return names[name];
}
}