-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
136 lines (116 loc) · 4.78 KB
/
index.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html>
<html>
<head>
<title>am i çu̻̲̣̟̣̞̮̔̈́ͨ͂̈ͩr͎͖̾ͥ́̏͊͊͑s͇͒ͮ̄ͯ̃̎͊ẻ̯͈̠̖̤̩ͤ̑̐͒d̳̥̰̟̥͔̾̇̌͐͑</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="./assets/javascript/application.js"></script>
<script src="./assets/javascript/web3.min.js"></script>
<link rel="shortcut icon" type="image/png" href="img/favicon.png">
<link rel="stylesheet" href="./assets/css/style.css">
</head>
<body class="centering" style="text-align: center">
<div id="curse-status" style="font-size:36px">Loading...</div>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<div id="curse-others" style="display:none;">
<input id="curse-victim" type="text" placeholder="0x0"><button id="curse-button" onclick="curse()">Curse a fool</button>
</div>
</body>
<br /><br /><br /><br /><br /><br />
<footer style="bottom:0;height:60px;">
<a href="https://github.com/CurseCoin/CurseCoin">github</a> | <a href="https://github.com/aleitner">aleitner</a> | <a href="https://github.com/navillasa">navillasa</a>
</footer>
</html>
<script>
let contractInstance;
function curse() {
let address = document.getElementById("curse-victim").value;
if (!address) {
return;
}
// TODO: Change value to be taken from contract
this.contractInstance.methods.curse(address).send({ from: web3.eth.defaultAccount, value: web3.utils.toWei("0.021", 'ether') }, function (error) {
if (error) {
console.log(error)
return;
}
alert('You have successfully cursed a helpless fool!');
document.getElementById('curse-victim').value = ''
});
}
function nullify() {
// TODO: Change value to be taken from contract
this.contractInstance.methods.nullify().send({ from: web3.eth.defaultAccount, value: web3.utils.toWei("0.021", 'ether') }, function (error) {
if (error) {
console.log(error)
return;
}
alert('You have successfully nullified the curse!');
});
}
function amicursed() {
this.contractInstance.methods.amICursed().call({ from: web3.eth.defaultAccount }, function (error, cursed) {
if (error) {
console.log(error);
return;
}
if (cursed) {
document.getElementById('curse-status').innerHTML = 'Y̖͍̲̜̫͈̒̐͌ͩ͆̂́̚o̸̖̙͈̫u̩̙͆ͣ̀ ͕̰͑ͨá̵̩̯̭͍̥̥̅̇ͣͥ̏r͍̥̬͈̗̲̫ͥ̕e̼̹̭ͭ̐ͭ͌ͭ̌̆͞ ҉͚͈̟c̡͔̉̀ͬͪ͒u̘̼̒̏́̾̓̓͐ṟ̤̞͇ͣs͇̝̖̪̯ͪ̑ͧ͒͐ͣ̔ê̋͏̞̖d̝͔͖͕ͧ<br /><br /><br /><button onclick="nullify()">Lift the Curse!</button>'
} else {
document.getElementById('curse-status').innerHTML = "You are not cursed";
}
});
}
function withdraw() {
this.contractInstance.methods.withdraw().send({ from: web3.eth.defaultAccount }, function (error) {
if (error != null) {
return alert(error)
}
return alert("Success took everyone's hard earned money!")
});
}
function loadContract() {
var self = this;
// Checking if Web3 has been injected by the browser (Mist/MetaMask)
if (typeof this.web3 !== 'undefined') {
// Use the browser's ethereum provider
var provider = web3.currentProvider;
} else {
document.getElementById('curse-status').innerHTML = "<a href=\"https://metamask.io/\">Install Metamask to check if you are cursed</a>"
return;
}
web3 = new Web3(provider);
web3.eth.net.getNetworkType().then((netId) => {
switch (netId) {
case "main":
self.contractInstance = new web3.eth.Contract(JSON.parse(contract_abi), mainnet);
break
case "ropsten":
self.contractInstance = new web3.eth.Contract(JSON.parse(contract_abi), ropsten);
break
case "rinkeby":
self.contractInstance = new web3.eth.Contract(JSON.parse(contract_abi), rinkeby);
break
case "kovan":
self.contractInstance = new web3.eth.Contract(JSON.parse(contract_abi), kovan);
break
default:
console.log('This is an unknown network.');
}
web3.eth.getAccounts(function (error, accounts) {
if (error != null) {
console.log(error)
return
}
document.getElementById('curse-others').style = 'display:auto;';
web3.eth.defaultAccount = accounts[0]
amicursed()
setInterval(function () {
amicursed()
}, 3000);
});
});
}
window.addEventListener('load', loadContract());
</script>