/
RealmKoin_Donation.sol
262 lines (244 loc) · 6.88 KB
/
RealmKoin_Donation.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
pragma solidity ^0.4.11;
// @library: solidity
// RealmKoin Donations Contract.
// Author: Skrypt
// GitHub: Www.Github.com/RealmKoin
// GitLab: git.techenterprises.me
// ProjectWeb: Www.RealmKoin.com
// SourceWeb: Www.TechEnterprises.me
// License Standard T.G.L(D: 2017) (The Guild License (Version Date: 2017*))
// (* Any And All Revised Future Editorials Of T.G.L Apply From 1/1/2017 To Date.)
// RealmKoin Ethereum Donations Smart Contract.
// Smart Contract That Has 0 Authorization To The RealmKoin Network.
// Sends Ethereum From Donations Account To Specified Address
// Appendable Ion For Network Connections.
// Ion Donate // Ion Functions.
// RealmKoin Network Contracts Are Public And RealmKoin Team Deployed ONLY.
// This Contract Requires Authenticated Callers.
// Fallback () Function Refers To Donations.
// Usage Extended To Public At A Later Date.
contract RealmKoin_Donations {
address public Stat_Signature;
uint public Total_Ions;
uint public Active_Ions;
address public Donations_Contract;
bool public Donations_Contract_Set;
bool private do_nothing;
uint256 public Donations;
uint256 public Total_Donations;
struct network_data {
bool Ion;
bool Stat;
}
struct ion_data {
address Ion_Signature;
}
mapping(address => network_data) public Network;
mapping(uint => ion_data) public Ion_Data;
event Donation_Sent(address _AdminSig, address _To, uint _MsgValue);
event Donated(address _AdminSig, address _To, uint _MsgValue);
event Donation_Received(address _From, uint _MsgValue);
event Set_Donations_Address(address _Admin, address _DonationAddress);
event Donations_Added(address _From, uint256 _MsgValue);
event Donation_Forwarded(address _From, address _To, uint256 _Value);
event MsgValue_Needed(address _Caller);
event MsgValue_Accepted(address _MsgValueSender);
event Donations_Unavailable(address _Admin, uint256 _Donations);
event Not_On_Network(address _CallerSig);
event Stat_Only_Option(address _CallerSig);
event Ion_Linked(address _NewIonSig);
event Ion_UnLinked(address _RemovedIonSig);
event Stat_Assigned(address _OldStat, address _NewStat);
modifier Is_Sender_Ion() {
if (Network[msg.sender].Ion != true) {
do_nothing = true;
Not_On_Network(msg.sender);
}
_;
}
modifier Is_Sender_Stat() {
if (Network[msg.sender].Stat != true) {
do_nothing = true;
Stat_Only_Option(msg.sender);
}
_;
}
modifier Value_Needed() {
if (msg.value == 0) {
do_nothing = true;
MsgValue_Needed(msg.sender);
}
_;
}
modifier Are_Donations_Available(uint256 _value) {
if (Donations < _value) {
do_nothing = true;
Donations_Unavailable(msg.sender, Donations);
}
_;
}
modifier MsgValue() {
if (msg.value > 0) {
do_nothing = false;
Donations += msg.value;
Total_Donations += msg.value;
MsgValue_Accepted(msg.sender);
}
_;
}
function RealmKoin_Donations(address _Stat) {
Donations = 0;
Total_Donations = 0;
Total_Ions = 0;
Active_Ions = 0;
Donations_Contract_Set = false;
Stat_Signature = _Stat;
Network[msg.sender].Ion = true;
Ion_Data[Total_Ions].Ion_Signature = msg.sender;
Total_Ions += 1;
Active_Ions += 1;
Network[_Stat].Ion = true;
Ion_Data[Total_Ions].Ion_Signature = _Stat;
Total_Ions += 1;
Active_Ions += 1;
Network[_Stat].Stat = true;
do_nothing = false;
}
function Link_Ion(address _NewIon) public payable
MsgValue()
Is_Sender_Stat()
returns (bool sucess)
{
if (do_nothing == true)
{
do_nothing = false;
return false;
}
else
{
Network[_NewIon].Ion = true;
Ion_Data[Total_Ions].Ion_Signature = _NewIon;
Total_Ions += 1;
Active_Ions += 1;
Ion_Linked(_NewIon);
return true;
}
}
function UnLink_Ion(address _IonSig) public payable
MsgValue()
Is_Sender_Stat()
returns (bool success)
{
if (do_nothing == true)
{
do_nothing = false;
return false;
}
else
{
Network[_IonSig].Ion = false;
Active_Ions -= 1;
Ion_UnLinked(_IonSig);
return true;
}
}
function Manual_Donate(address _to, uint256 _value) public payable // If No Donations Contract (Auto-Send) Has Been Set
MsgValue()
Is_Sender_Ion()
Are_Donations_Available(_value)
returns (bool sucess)
{
if (do_nothing == true)
{
do_nothing = false;
return false;
}
else
{
if (!_to.call.value(_value)()) {
return false;
}
else
{
Donation_Sent(msg.sender, _to, _value);
Donations -= _value;
return true;
}
}
}
function Set_Donations_Contract(address _d_set) public payable
MsgValue()
Is_Sender_Stat()
returns (bool sucess)
{
if (do_nothing == true)
{
do_nothing = false;
return false;
}
else
{
Donations_Contract = _d_set;
Donations_Contract_Set = true;
Set_Donations_Address(msg.sender, _d_set);
return true;
}
}
function Assign_Stat(address _NewStat)
public payable
MsgValue()
Is_Sender_Stat()
returns (bool success)
{
if (do_nothing == true) {
do_nothing = false;
return false;
}
else
{
Network[msg.sender].Stat = false;
Network[msg.sender].Ion = false;
Stat_Signature = _NewStat;
Network[_NewStat].Stat = true;
Network[_NewStat].Ion = true;
Stat_Assigned(msg.sender, _NewStat);
return true;
}
}
function Disengage(address _Beneficiary) public
Is_Sender_Stat()
returns (bool success)
{
if (do_nothing == true)
{
do_nothing = false;
return false;
}
else
{
selfdestruct(_Beneficiary);
return true;
}
}
function() payable
{
if (Donations_Contract_Set == true) {
if (!Donations_Contract.call.value(msg.value)()) {
Total_Donations += msg.value;
Donation_Forwarded(msg.sender, Donations_Contract, msg.value);
}
else
{
Donations += msg.value;
Total_Donations += msg.value;
Donation_Received(msg.sender, msg.value);
}
}
else
{
Total_Donations += msg.value;
Donations += msg.value;
Donation_Received(msg.sender, msg.value);
}
}
}