-
Notifications
You must be signed in to change notification settings - Fork 2
/
2020oasisnobelprizecommenter_1602562442967.html
148 lines (135 loc) · 14.1 KB
/
2020oasisnobelprizecommenter_1602562442967.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
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>2020-oasis-nobel-prize-commenter</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />
<style type="text/css">
</style>
</head>
<body>
<div class="container">
<br/>
<div class="jumbotron">
<div class="view overlay rounded-top text-center">
<img src="" class="img-fluid" id="image">
</div>
<div class="card-body text-center mb-3">
<p class="card-text py-2" id="message"></p>
</div>
<hr/>
<form id="form">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" id="name" placeholder="">
</div>
<div class="form-group">
<label for="comment">Comment</label>
<input type="text" class="form-control" id="comment" placeholder="">
</div>
<p><span id="balance"></span><span id="pricealert"></span></p>
<button type="button" id="submit" class="btn btn-primary">Pay & Comment</button>
</form>
<div id="formSubmitted" style="display:none">Please wait up to 10 seconds for confirmation ...</div>
</div>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody id="comments">
</tbody>
</table>
<p style="text-align:center">All data recorded on the <a target="_blank" href="https://www.oasiseth.org">Oasis Ethereum</a> blockchain network.</p>
</div>
<script type="text/javascript">
window.BuidlProviders = {
web3: {
url: "https://rpc.oasiseth.org:8545",
chainId: "69",
gasPrice: "1",
gasLimit: "8000000",
},
es: {
url: "https://devchain.ss.search.secondstate.io"
}
}
</script>
<script type="text/javascript" src="https://buidl.secondstate.io/embed/main.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
/* Don't modify */
var abi = [{"constant":false,"inputs":[{"name":"_message","type":"string"}],"name":"setMessage","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getAddrs","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_image","type":"string"}],"name":"setImage","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_price","type":"uint256"}],"name":"setPrice","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"price","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"},{"name":"_comment","type":"string"}],"name":"addComment","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"message","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"image","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_addr","type":"address"}],"name":"getComment","outputs":[{"name":"","type":"string"},{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_message","type":"string"},{"name":"_image","type":"string"},{"name":"_price","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}];
var bytecode = '6060604052341561000f57600080fd5b604051610f6c380380610f6c83398101604052808051820191906020018051820191906020018051906020019091905050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600190805190602001906100969291906100bd565b5081600290805190602001906100ad9291906100bd565b5080600381905550505050610162565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100fe57805160ff191683800117855561012c565b8280016001018555821561012c579182015b8281111561012b578251825591602001919060010190610110565b5b509050610139919061013d565b5090565b61015f91905b8082111561015b576000816000905550600101610143565b5090565b90565b610dfb806101716000396000f3006060604052600436106100a4576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063368b8772146100a95780633ccfd60b146101065780633f416eb31461011b57806371adb5e61461018557806391b7f5ed146101e2578063a035b1fe14610205578063ae5ff9051461022e578063e21f37ce146102c3578063f3ccaac014610351578063f6bb0cf1146103df575b600080fd5b34156100b457600080fd5b610104600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506104fd565b005b341561011157600080fd5b610119610572565b005b341561012657600080fd5b61012e610647565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610171578082015181840152602081019050610156565b505050509050019250505060405180910390f35b341561019057600080fd5b6101e0600480803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506106db565b005b34156101ed57600080fd5b6102036004808035906020019091905050610750565b005b341561021057600080fd5b6102186107b5565b6040518082815260200191505060405180910390f35b6102c1600480803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509190803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919050506107bb565b005b34156102ce57600080fd5b6102d6610945565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103165780820151818401526020810190506102fb565b50505050905090810190601f1680156103435780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561035c57600080fd5b6103646109e3565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103a4578082015181840152602081019050610389565b50505050905090810190601f1680156103d15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34156103ea57600080fd5b610416600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a81565b604051808060200180602001838103835285818151815260200191508051906020019080838360005b8381101561045a57808201518184015260208101905061043f565b50505050905090810190601f1680156104875780820380516001836020036101000a031916815260200191505b50838103825284818151815260200191508051906020019080838360005b838110156104c05780820151818401526020810190506104a5565b50505050905090810190601f1680156104ed5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390f35b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561055857600080fd5b806001908051906020019061056e929190610c56565b5050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156105cd57600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc3073ffffffffffffffffffffffffffffffffffffffff16319081150290604051600060405180830381858888f19350505050151561064557600080fd5b565b61064f610cd6565b60058054806020026020016040519081016040528092919081815260200182805480156106d157602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610687575b5050505050905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561073657600080fd5b806002908051906020019061074c929190610c56565b5050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156107ab57600080fd5b8060038190555050565b60035481565b60035434101515156107cc57600080fd5b600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060020160009054906101000a900460ff16151561088657600580548060010182816108369190610cea565b9160005260206000209001600033909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505b60606040519081016040528083815260200182815260200160011515815250600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000820151816000019080519060200190610900929190610d16565b50602082015181600101908051906020019061091d929190610d16565b5060408201518160020160006101000a81548160ff0219169083151502179055509050505050565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109db5780601f106109b0576101008083540402835291602001916109db565b820191906000526020600020905b8154815290600101906020018083116109be57829003601f168201915b505050505081565b60028054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a795780601f10610a4e57610100808354040283529160200191610a79565b820191906000526020600020905b815481529060010190602001808311610a5c57829003601f168201915b505050505081565b610a89610d96565b610a91610d96565b600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600001600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600101818054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610baa5780601f10610b7f57610100808354040283529160200191610baa565b820191906000526020600020905b815481529060010190602001808311610b8d57829003601f168201915b50505050509150808054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610c465780601f10610c1b57610100808354040283529160200191610c46565b820191906000526020600020905b815481529060010190602001808311610c2957829003601f168201915b5050505050905091509150915091565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610c9757805160ff1916838001178555610cc5565b82800160010185558215610cc5579182015b82811115610cc4578251825591602001919060010190610ca9565b5b509050610cd29190610daa565b5090565b602060405190810160405280600081525090565b815481835581811511610d1157818360005260206000209182019101610d109190610daa565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10610d5757805160ff1916838001178555610d85565b82800160010185558215610d85579182015b82811115610d84578251825591602001919060010190610d69565b5b509050610d929190610daa565b5090565b602060405190810160405280600081525090565b610dcc91905b80821115610dc8576000816000905550600101610db0565b5090565b905600a165627a7a723058203d54d48b7ab7bc0b3bf0756628d59d7f774d8b9a576caff07a6c544bda9d02f70029';
var cAddr = '0xa0fabfb8d2f22892255d0f600b6f2fb64c62f83a';
/* Don't modify */
var instance = null;
window.addEventListener('web3Ready', function() {
var contract = web3.ss.contract(abi);
instance = contract.at(cAddr);
reload();
});
var price = "0"; // This is in the unit of OETH. e.g., 0.01
function reload() {
instance.message(function (e, r) {
$("#message").html(r);
});
instance.image(function (e, r) {
$("#image").prop("src", r);
});
instance.price(function (e, r) {
price = r;
$("#pricealert").html("Requires " + price + " wei to comment");
});
$("#formSubmitted").css("display", "none");
web3.ss.getAccounts(function (e, address) {
if (!e) {
var balance = web3.ss.getBalance(address[0]);
$("#balance").html("You have " + balance + " wei OETH in your current account. ");
var comments = "";
instance.getAddrs(function (ee, addrs) {
addrs.forEach(function(addr) {
instance.getComment(addr, function (ee, r) {
if (!ee) {
comments = comments + "<tr><td>" + r[0] + "</td><td>" + r[1] + "</td></tr>";
$("#comments").html(comments);
}
});
});
});
$("#comments").html(comments);
}
});
}
$("#submit").click(function() {
if ((!$("#name").val().trim()) || (!$("#comment").val().trim())) {
alert("Please enter both a name and a comment");
return false;
}
web3.ss.getAccounts(function (e, address) {
if (!e) {
$("#form").css("display", "none");
$("#formSubmitted").css("display", "block");
instance.addComment ($("#name").val(), $("#comment").val(), {
value: price,
gas: 499000,
gasPrice: 1
}, function (ee, r) {
if (ee) {
window.alert("You need to pay " + price + " OETH to comment. Make sure that you have it in your address.");
}
});
setTimeout(function () {
reload ();
}, 10 * 1000);
}
});
return false;
});
</script>
</body>
</html>