-
Notifications
You must be signed in to change notification settings - Fork 5
/
functions.js
499 lines (466 loc) · 17 KB
/
functions.js
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
// MAZE (mining)
function reward() {
var content = "";
//content += zombieMaster;
$("#lang").html(content);
var event = contractMaze.methods.getMiningReward().call()
.then(function (result) {
var content = "<br>Mining reward: ";
console.log(result);
content += JSON.stringify(result.toString()/1000000);
$("#lang").html(content);
});;
};
function minted() {
var content = "";
//content += zombieMaster;
$("#lang1").html(content);
var event = contractMaze.methods.tokensMinted().call()
.then(function (result) {
var content = "<br>Minted amount: ";
console.log(result);
content += JSON.stringify(result.toString()/1000000);
$("#lang1").html(content);
});;
};
// Faucet (ZOMBIE)
function claimZombie() {
var content = "Sending transaction from: ";
content += zombieMaster;
$("#lang").html(content);
var event = contractFaucet.methods.claimZombie(zombieMaster).send({ from: zombieMaster })
.then(function (receipt) {
console.log(receipt);
var content = "Transaction sent!: ";
content += JSON.stringify(receipt.transactionHash);
$("#lang").html(content);
});;
};
function lockTimeZ() {
var event = contractFaucet.methods.lockTime(zombieMaster).call()
.then(function (result) {
var content = "Next claim on: ";
console.log(result);
//alert(result);
var a = new Date(result * 1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
var sec = a.getSeconds();
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
alert(time);
//return time;
//content += JSON.stringify(result.toString());
content += JSON.stringify(time.toString());
$("#lang1").html(content);
});;
};
function balanceFaucet() {
//var content = "Your address: ";
//content += zombieMaster;
//$("#lang2").html(content);
var event = contractZombie.methods.balanceOf("0xE6fBa59BDf1EafA8b1B5ad57D9C4A354CA55D756").call()
.then(function (result) {
var content = "ZOMBIE faucet balance: ";
alert(result);
content += JSON.stringify(result.toString());
$("#lang2").html(content);
});;
};
// Faucet (URGD)
function claimURGD() {
var content = "Sending transaction from: ";
content += zombieMaster;
$("#lang3").html(content);
var event = contractFaucet2.methods.claimToken(zombieMaster).send({ from: zombieMaster, value: 20000000000000 })
.then(function (receipt) {
console.log(receipt);
var content = "Transaction sent!: ";
content += JSON.stringify(receipt.transactionHash);
$("#lang3").html(content);
});;
};
function lockTimeU() {
//var content = "Your address: ";
//content += zombieMaster;
//$("#lang4").html(content);
var event = contractFaucet2.methods.lockTime(zombieMaster).call()
.then(function (result) {
var content = "Next claim on: ";
//alert(result);
console.log(result);
var a = new Date(result * 1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
var sec = a.getSeconds();
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
alert(time);
//return time;
//content += JSON.stringify(result.toString());
content += JSON.stringify(time.toString());
$("#lang4").html(content);
});;
};
function balanceFaucet2() {
//var content = "Your address: ";
//content += zombieMaster;
//$("#lang5").html(content);
var event = contractUnderground.methods.balanceOf("0x6FAE0c62687EdCCDe384eD12cC0513c7436A4b5C").call()
.then(function (result) {
var content = "URGD faucet balance: ";
alert(result/100000000);
content += JSON.stringify(result.toString()/100000000);
$("#lang5").html(content);
});;
};
// Stake ZOMBIE (Vandals Bank)
function approveZ() {
var amount1 = $("#amount1").val();
// var amount2 = amount1 *100000000;
// ZOMBIE has 0 decimals
var amount2 = amount1 *1;
var amount3 = amount2.toString();
var content = "Approving transaction from: ";
content += zombieMaster;
$("#lang").html(content);
var event = contractZombie.methods.approve("0xBc6af81CE1bFae76a4cF6eD5BCE128e6FD2f0633", amount3).send({ from: zombieMaster })
.then(function (receipt) {
console.log(receipt);
var content = "Approved!: ";
alert("Done. The horde is ready!")
content += JSON.stringify(receipt.transactionHash);
$("#lang").html(content);
});;
};
function stakeTokens() {
var amount1 = $("#amount1").val();
// var amount2 = amount1 *100000000;
// ZOMBIE has 0 decimals
var amount2 = amount1 *1;
var amount3 = amount2.toString();
var content = "Sending transaction from: ";
content += zombieMaster;
$("#lang1").html(content);
var event = contractBank.methods.stakeTokens(amount3).send({ from: zombieMaster })
.then(function (receipt) {
console.log(receipt);
var content = "Transaction sent!: ";
alert("Done. Zombies are in the Vandals Bank now!");
content += JSON.stringify(receipt.transactionHash);
$("#lang1").html(content);
});;
};
function stakingBalance() {
//var content = "Check your balance staked: ";
//content += zombieMaster;
//$("#lang2").html(content);
var event = contractBank.methods.stakingBalance(zombieMaster).call()
.then(function (result) {
var content = "Your balance staked is: ";
alert(result);
content += JSON.stringify(result.toString());
$("#lang2").html(content);
});;
};
function claimTokens() {
var content = "Sending transaction from: ";
content += zombieMaster;
$("#lang3").html(content);
var event = contractBank.methods.harvestTokens(zombieMaster).send({ from: zombieMaster })
.then(function (receipt) {
console.log(receipt);
var content = "Transaction sent!: ";
alert("Done. Long live VANDALS!");
content += JSON.stringify(receipt.transactionHash);
$("#lang3").html(content);
});;
};
function lockTimeB() {
var event = contractBank.methods.lockTime(zombieMaster).call()
.then(function (result) {
var content = "Next claim on: ";
//alert(result);
console.log(result);
var a = new Date(result * 1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
var sec = a.getSeconds();
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
alert(time);
//return time;
//content += JSON.stringify(result.toString());
content += JSON.stringify(time.toString());
$("#lang4").html(content);
});;
};
function unstakeTokens() {
var content = "Sending transaction from: ";
content += zombieMaster;
$("#lang5").html(content);
var event = contractBank.methods.unstakeTokens().send({ from: zombieMaster })
.then(function (receipt) {
console.log(receipt);
var content = "Transaction sent! ";
alert("Done. You`ve been zombified again!");
content += JSON.stringify(receipt.transactionHash);
$("#lang5").html(content);
});;
};
function balanceBank() {
var event = contractVandals.methods.balanceOf("0xBc6af81CE1bFae76a4cF6eD5BCE128e6FD2f0633").call()
.then(function (result) {
var content = "Vandals Bank balance: ";
alert(result/100000000);
content += JSON.stringify(result.toString()/100000000);
$("#lang6").html(content);
});;
};
// Stake MAZE (Vandals Bank)
function approveM() {
var amount4 = $("#amount4").val();
var amount5 = amount4 *1000000;
var amount6 = amount5.toString();
var content = "Approving transaction from: ";
content += zombieMaster;
$("#lang7").html(content);
var event = contractMaze.methods.approve("0x381Fe35FCcA720efda008Ed182D0210519928638", amount6).send({ from: zombieMaster })
.then(function (receipt) {
console.log(receipt);
var content = "Approved!: ";
alert("Done!")
content += JSON.stringify(receipt.transactionHash);
$("#lang7").html(content);
});;
};
function stakeTokens2() {
var amount4 = $("#amount4").val();
var amount5 = amount4 *1000000;
var amount6 = amount5.toString();
var content = "Sending transaction from: ";
content += zombieMaster;
$("#lang8").html(content);
var event = contractBank2.methods.stakeTokens(amount6).send({ from: zombieMaster })
.then(function (receipt) {
console.log(receipt);
var content = "Transaction sent!: ";
alert("Done!");
content += JSON.stringify(receipt.transactionHash);
$("#lang8").html(content);
});;
};
function stakingBalance2() {
//var content = "Check your balance staked: ";
//content += zombieMaster;
//$("#lang9").html(content);
var event = contractBank2.methods.stakingBalance(zombieMaster).call()
.then(function (result) {
var content = "Your balance staked is: ";
alert(result/1000000);
content += JSON.stringify(result.toString()/1000000);
$("#lang9").html(content);
});;
};
function claimTokens2() {
var content = "Sending transaction from: ";
content += zombieMaster;
$("#lang10").html(content);
var event = contractBank2.methods.claimTokens(zombieMaster).send({ from: zombieMaster, value: 20000000000000 })
.then(function (receipt) {
console.log(receipt);
var content = "Transaction sent!: ";
alert("Done!");
content += JSON.stringify(receipt.transactionHash);
$("#lang10").html(content);
});;
};
function lockTimeUn() {
var event = contractBank2.methods.lockTime(zombieMaster).call()
.then(function (result) {
var content = "Next claim on: ";
//alert(result);
console.log(result);
var a = new Date(result * 1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
var sec = a.getSeconds();
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
alert(time);
//return time;
//content += JSON.stringify(result.toString());
content += JSON.stringify(time.toString());
$("#lang11").html(content);
});;
};
function unstakeTokens2() {
var content = "Sending transaction from: ";
content += zombieMaster;
$("#lang12").html(content);
var event = contractBank2.methods.unstakeTokens().send({ from: zombieMaster })
.then(function (receipt) {
console.log(receipt);
var content = "Transaction sent! ";
alert("Done!");
content += JSON.stringify(receipt.transactionHash);
$("#lang12").html(content);
});;
};
function balanceBank2() {
var event = contractUnderground.methods.balanceOf("0x381Fe35FCcA720efda008Ed182D0210519928638").call()
.then(function (result) {
var content = "Vandals Bank balance: ";
alert(result/100000000);
content += JSON.stringify(result.toString()/100000000);
$("#lang13").html(content);
});;
};
// Stake Funky Bots NFT (Vandals Bank)
function approveF() {
var tokenId = $("#tokenId").val();
var content = "Approving transaction from: ";
content += zombieMaster;
$("#lang14").html(content);
var event = contractFunkyBots.methods.approve("0x180B9fDc7E851BAE34E408a26F55D2EfA95320c0", tokenId).send({ from: zombieMaster })
.then(function (receipt) {
console.log(receipt);
var content = "Approved!: ";
alert("Done. You can stake it now!")
content += JSON.stringify(receipt.transactionHash);
$("#lang14").html(content);
});;
};
function stakeNFT() {
var tokenId = $("#tokenId").val();
var content = "Sending transaction from: ";
content += zombieMaster;
$("#lang15").html(content);
var event = contractBankNFT.methods.stake(tokenId).send({ from: zombieMaster })
.then(function (receipt) {
console.log(receipt);
var content = "Transaction sent!: ";
alert("Done. FunkyBot is in the Vandals Bank now!");
content += JSON.stringify(receipt.transactionHash);
$("#lang15").html(content);
});;
};
function calculateReward() {
var tokenId = $("#tokenId1").val();
var event = contractBankNFT.methods.calculateTokens(tokenId).call()
.then(function (result) {
var content = "VANDALS amount: ";
alert(result/100000000);
content += JSON.stringify(result.toString()/100000000);
$("#lang16").html(content);
});;
};
function unstakeNFT() {
var tokenId = $("#tokenId2").val();
var content = "Sending transaction from: ";
content += zombieMaster;
$("#lang17").html(content);
var event = contractBankNFT.methods.unstake(tokenId).send({ from: zombieMaster, value: 50000000000000 })
.then(function (receipt) {
console.log(receipt);
var content = "Transaction sent! ";
alert("Done.");
content += JSON.stringify(receipt.transactionHash);
$("#lang17").html(content);
});;
};
function balanceBankNFT() {
var event = contractVandals.methods.balanceOf("0x180B9fDc7E851BAE34E408a26F55D2EfA95320c0").call()
.then(function (result) {
var content = "Vandals Bank balance: ";
alert(result/100000000);
content += JSON.stringify(result.toString()/100000000);
$("#lang18").html(content);
});;
};
// URGD
function totalFees() {
//var content = "Your address: ";
//content += zombieMaster;
//$("#lang").html(content);
var event = contractUnderground.methods.totalFees().call()
.then(function (result) {
var content = "Total URGD fees (half is burned): ";
alert(result/100000000);
content += JSON.stringify(result.toString()/100000000);
$("#lang").html(content);
});;
};
// PostBox
function sendMessage() {
var sender = $("#sender").val();
var recipient = $("#recipient").val();
var message = $("#message").val();
var url = $("#url").val();
var content = "Sending transaction from: ";
content += zombieMaster;
$("#lang").html(content);
var event = contractPostBox.methods.sendMessage(sender, recipient, message, url).send({ from: zombieMaster, value: 10000000000000 })
.then(function (receipt) {
console.log(receipt);
var content = "Transaction sent!: ";
alert("Done!");
content += JSON.stringify(receipt.transactionHash);
$("#lang").html(content);
});;
};
function viewMessage() {
var id = $("#id").val();
var event = contractPostBox.methods.messages(id).call()
.then(function (result) {
var content = "Post Box message: <br><br>";
console.log(result);
// content += JSON.stringify({ id: result[0], from: result[1], to: result[2], message: result[3], url: result[4] }, null, 2);
content += "id: " + result[0] + " | " + "from: " + result[1] + " | " + "to: " + result[2] + " | " + "message: " + result[3] + " | " + "URL: " + result[4];
$("#lang1").html(content);
});;
};
function countMessage() {
var event = contractPostBox.methods.messageCount().call()
.then(function (result) {
var content = "Total messages: ";
console.log(result);
//content += JSON.stringify(result.toString());
content += result;
$("#lang2").html(content);
});;
};
function viewLatest() {
var event = contractPostBox.methods.message().call()
.then(function (result) {
var content = "Post Box message: <br><br>";
console.log(result);
//content += JSON.stringify(result.toString());
content += result;
$("#lang3").html(content);
});;
};
function allMessages() {
var content = "";
for(i = 1; i < 20; i++) {
var event = contractPostBox.methods.messages(i).call()
.then(function (result) {
console.log(result);
//content += JSON.stringify({ id: result[0], from: result[1], to: result[2], message: result[3], url: result[4] }, null, 2);
content += "<tr>" + "<td>" + "id: " + result[0] + "</td>" + "<td>" + "from: " + result[1] + "</td>" + "<td>" + "to: " + result[2] + "</td>" + "<td>" + "message: " + result[3] + "</td>" + "<td>" + "URL: " + result[4] + "</td>" + "</tr>";
$("#lang4").html(content);
});;
}
};