-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHugCoin.eth
More file actions
93 lines (69 loc) · 2.42 KB
/
Copy pathHugCoin.eth
File metadata and controls
93 lines (69 loc) · 2.42 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
Sometimes you want to hug someone but there is noone around. How sad!
NO MORE!
HugCoin, is a futuristic way to say, I am there for you. Or just an experimentation
with Ethereum. Whatever rocks your boat.
Everybody has an infinite amount of HugCoins to give
*and*
whenever you receive a hug, you are getting added FOREVER in the blockchain.
Read more about this and how you can use:
http://jon.io/hugcoin.html
HugCoin is implemented as an ERC20 compatible token. Additional methods are provided so you can hug someone and add his/her name on the blockchain.
Jon V
*/
contract HugCoin {
string public name = 'HugCoin';
string standard = 'HugCoin 0.2';
string public symbol = '<3';
uint8 decimals = 0;
address owner;
uint8 constant a_hug = 1;
uint public totalHuggers = 0;
Member[] public hugged;
mapping (address => uint256) public balanceOf;
/* This generates a public event on the blockchain that will notify clients */
event Transfer(address indexed _from, address indexed _to, uint256 _value);
struct Member {
address member;
string name;
uint memberSince;
}
modifier isOwner {
if (msg.sender != owner) throw;
_
}
function HugCoin(string sym) {
symbol = sym;
owner = msg.sender;
// The first hug, goes to me!
giveHugTo("Jon V", msg.sender);
msg.sender.send(msg.value);
}
function transfer(address _to, uint256 _value) returns (bool success) {
balanceOf[_to] += a_hug;
totalHuggers += 1;
Transfer(msg.sender, _to, a_hug);
return true;
}
/* Send hugs */
function giveHugTo(string receipient_name, address _to) returns (bool success){
if (balanceOf[_to] == 0) {
// new hugger!
hugged[hugged.length++] = Member({member: _to, name:receipient_name, memberSince: now});
balanceOf[_to] = a_hug;
totalHuggers += 1;
}
else {
balanceOf[_to] += a_hug;
}
Transfer(msg.sender, _to, a_hug);
return true;
}
function destroy() isOwner {
suicide(owner);
}
/* This unnamed function is called whenever someone tries to send ether to it */
function () {
throw; // Prevents accidental sending of ether
}
}