-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdns2.solidity
75 lines (65 loc) · 1.69 KB
/
dns2.solidity
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
contract dns2
{
struct nameData
{
address owner;
uint32 ipv4;
uint128 ipv6;
bool isIpv6;
}
mapping (string => nameData) names;
address deployer;
function dns2()
{
deployer = msg.sender;
}
function claim(string name) returns (bool success)
{
if (names[name].owner != 0) return false;
names[name].owner = msg.sender;
return true;
}
function setIpv4(string name, uint32 ip) returns (bool success)
{
if (names[name].owner != msg.sender) return false;
names[name].ipv4 = ip;
names[name].ipv6 = 0;
names[name].isIpv6 = false;
return true;
}
function setIpv6(string name, uint128 ip) returns (bool success)
{
if (names[name].owner != msg.sender) return false;
names[name].ipv6 = ip;
names[name].ipv4 = 0;
names[name].isIpv6 = true;
return true;
}
function give(string name, address recipient) returns (bool success)
{
if (names[name].owner != msg.sender) return false;
names[name].owner = recipient;
return true;
}
function owner(string name) returns (address retVal)
{
return names[name].owner;
}
function ipv4(string name) returns (uint32 retVal)
{
return names[name].ipv4;
}
function ipv6(string name) returns (uint128 retVal)
{
return names[name].ipv6;
}
function isIpv6(string name) returns (bool retVal)
{
return names[name].isIpv6;
}
function getDonations()
{
if (msg.sender != deployer) return;
deployer.send(this.balance);
}
}