-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdennyslotto.html
122 lines (112 loc) · 3.56 KB
/
dennyslotto.html
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
<html>
<head>
<title>Hot Russian Grills want to date you!</title>
<style>
body {
font-family: Gentium, Georgia, serif
}
h1, h2 {
font-family: Trebuchet MS, sans
}
h1 {
font-size: 16pt
}
h2 {
font-size: 13pt
}
div {
margin-left: 8pt;
}
img {
margin: 4pt;
padding: 6pt;
}
</style>
<script>
var lottoAddr = key.addressOf("1d44f704ee5ebf08bda0407ef8a438cc026751f2");
buyticket = function()
{
var ticketnum = Number(document.getElementById("ticket").value);
if ((ticketnum<0)||(ticketnum>99)) {
window.alert("Ticket numbers are in [0,99]")
window.alert("Do it right next time!")
return;
};
if (ticketnum != "")
eth.transact(key.secret(eth.keys()[0]), u256.ether(2), lottoAddr, u256.bytesOf(u256.value(ticketnum)), u256.value(10000), eth.gasPrice());
}
lookupTickets = function()
{
var myTable= "<table><tr><td style='width: 100px; color: red;'>Your Tickets</td></tr>";
myTable+="<tr><td style='width: 100px; '>---------------</td></tr>";
var location = 8;
var myaddrs = eth.keys();
var myaddr = 0;
var check =0;
for (var i = 0; i < myaddrs.length; i++) {
myaddr = u256.toValue(u256.fromAddress(key.address(myaddrs[i])));
while (!u256.isNull(eth.storageAt(lottoAddr, u256.value(location)))) {
check = u256.toValue(eth.storageAt(lottoAddr, u256.value(location)));
if (check == myaddr) {
myTable+="<tr><td style='width: 100px;'>" + u256.toValue(eth.storageAt(lottoAddr, u256.value(location+1))) + "</td></tr>";
};
location=location+2;
};
};
myTable+="</table>";
document.getElementById('TicketTable').innerHTML = myTable;
}
claim = function()
{
var r=confirm("Are you sure? Your money is safe with me!");
if (r==true)
{
var myaddrs = eth.keys();
for (var i = 0; i < myaddrs.length; i++) {
eth.transact(key.secret(myaddrs[i]), u256.ether(0), lottoAddr, u256.bytesOf(u256.value(0)), u256.value(10000), eth.gasPrice());
};
}
else
{
return;
}
}
check = function()
{
var myaddrs = eth.keys();
var myaddr = 0;
bal = 0;
for (var i = 0; i < myaddrs.length; i++) {
myaddr = u256.fromAddress(key.address(myaddrs[i]));
bal = bal+u256.toValue(eth.storageAt(lottoAddr,myaddr));
};
var win = bal/1000000000000000000;
var winning= "<h1><font style=' color: red;'>" + win.toFixed(2) + " E</font></h1>";
document.getElementById('winnings').innerHTML = winning;
}
lookupJackpot = function()
{
var Jackpot = u256.toValue(eth.storageAt(lottoAddr,u256.value(6)))/1000000000000000000;
var JACKP = "<h1><font style=' color: red;'>" + Jackpot.toFixed(2) + " E</font></h1>";
document.getElementById('jackpt').innerHTML = JACKP;
}
</script>
</head>
<body>
<h1>Denny's Lotto</h1>
<h2>(Totally not a scam you can trust me)</h2>
<b>The Jackpot is:</b><div id="jackpt"> </div>
<button onClick="lookupJackpot()">Whats the Jackpot?</button><br>
-------------------------------------------------------------
<table>
<tr><td>BUY TICKETS!</td><td> </td></tr>
<tr><td><label for="name">Ticket Num: </label></td><td><input id="ticket" type="text" value=""/><button onClick="buyticket()">BUY!</button></td></tr>
</table>
<button onClick="lookupTickets()">Find My Tickets!</button>
<div id="TicketTable"> </div><br>
-------------------------------------------------------------
<b>Your Winnings:</b><div id="winnings"> </div>
<button onClick="check()">Check</button><button onClick="claim()">Claim</button>
<h6>Tickets cost 2 ether each. Ticket numbers are between 0 and 99. The draw happens every 16 blocks. If you get the have the winning ticket you win the JACKPOT*. If you have the same 1's digit you win 5 ether!!</h6>
</body>
</html>