forked from ethgasstation/ethgasstation-frontend
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pendingTxReport.php
executable file
·392 lines (330 loc) · 15.2 KB
/
pendingTxReport.php
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
<?php require_once 'build/php/common.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo EGS_TITLE; ?> | Consumer oriented metrics for the Ethereum gas market </title>
<meta name="keywords" content="Ethereum ETH gas blockchain market price transactions miners users">
<meta name="description" content="<?php echo EGS_DESCRIPTION; ?>">
<meta property="og:title" content="<?php echo EGS_TITLE; ?>" />
<meta property="og:type" content="website" />
<meta property="og:image" content="images/ETHGasStation.png" />
<meta property="og:url" content="https://<?php echo EGS_HOSTNAME; ?>" />
<!-- Bootstrap -->
<link href="vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<!--Favicon-->
<link rel="apple-touch-icon" sizes="57x57" href="images/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="images/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="images/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="images/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="images/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="images/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="images/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="images/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="images/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="images/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="images/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="images/ms-icon-144x144.png">
<meta name="theme-color" content="#ffffff">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-134672026-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-134672026-1');
</script>
<!-- Custom Theme Style -->
<link href="build/css/custom.css" rel="stylesheet">
<?php include 'build/php/minerT_py.php'; ?>
</head>
<body class="nav-md">
<?php include 'unofficial.php'; ?>
<div class="container body">
<div class="main_container">
<!-- Sidebar -->
<?php include 'sidebar.php'; ?>
<!-- top navigation -->
<div class="top_nav">
<div class="nav_menu">
<nav>
<div class="nav toggle">
<a id="menu_toggle"><i class="fa fa-bars"></i></a>
</div>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><i class="fa fa-globe"></i><span style="color:#768399"> Change Currency</span>
<span class=" fa fa-angle-down"></span>
</a>
<ul class="dropdown-menu">
<li id="usd"><a href="#"> USD<?php if($currency=='usd'){echo'<span class="pull-right"><i class="fa fa-check"></i></span>';}?></a></li>
<li id="eur"><a href="#"> EUR<?php if($currency=='eur'){echo'<span class="pull-right"><i class="fa fa-check"></i></span>';}?></a></li>
<li id="gbp"><a href="#"> GBP<?php if($currency=='gbp'){echo'<span class="pull-right"><i class="fa fa-check"></i></span>';}?></a></li>
<li id="cny"><a href="#"> CNY<?php if($currency=='cny'){echo'<span class="pull-right"><i class="fa fa-check"></i></span>';}?></a></li>
</ul>
</li>
<p class="navbar-text navbar-left" style="padding-left: 5px"><strong><?php echo "Last update: Block <span style = 'color:#1ABB9C'> $bnum" ?></strong></span>
</p>
</ul>
</nav>
</div>
</div>
<!-- /top navigation -->
<!-- page content -->
<div class="right_col" role="main">
<div class="row">
<div class="col-md-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h4>Search for Transaction in the Txpool</h4>
<div class="clearfix"></div>
</div>
<div class="x_content">
<br />
<form class="form-horizontal form-label-left input_mask">
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Tx Hash<span class="required">*</span></label>
<div class="col-md-9 col-sm-9 col-xs-12">
<input type="text" class="form-control" placeholder="0x...." id="txhash">
</div>
</div>
</div>
</div>
</div>
<div class="ln_solid"></div>
<div class="form-group">
<div class="col-md-12 col-sm-12 col-xs-12 col-md-offset-3">
<button class="btn btn-primary" type="reset" id="reset">Reset</button>
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</div>
</br>
</form>
<div class="row">
<div class="col-md-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h4 id="txArgs">Pending Transaction Report:</h4>
<div class="clearfix"></div>
</div>
<div class="x_content">
<table class="table table-bordered">
<thead>
<tr>
<th>Outcome</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Block Posted</td>
<td id="bp"></td>
</tr>
<tr>
<td>Actual Blocks Waiting</td>
<td id="blockswaiting"></td>
</tr>
<tr>
<td>Predicted Blocks Waiting for Confirmation</td>
<td id="meanBlocks"></td>
</tr>
<tr>
<td>Probability mined in less than 1 hour</td>
<td id="minedprob"></td>
</tr>
<tr>
<td>Gas Price (Gwei)</td>
<td id="gp"></td>
</tr>
<tr>
<td>Gas Offered</td>
<td id="go"></td>
</tr>
<tr>
<td>% of last 200 blocks accepting this gas price</td>
<td id="hp"></td>
</tr>
<tr>
<td>Transactions At or Above in Current Txpool</td>
<td id="txatabove"></td>
</tr>
<tr>
<td>Max Transaction fee (ETH)</td>
<td id="txEth"></td>
</tr>
<tr>
<td>Max Transaction fee (Fiat)</td>
<td id="txFiat"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- /misc transactions -->
</div>
</div>
<!-- /page content -->
<!-- footer content -->
<footer>
<div class="pull-right">
Gentelella - Bootstrap Admin Template by <a href="https://colorlib.com">Colorlib</a>
</div>
<div class="clearfix"></div>
</footer>
<!-- /footer content -->
</div>
</div>
<!-- jQuery -->
<script src="vendors/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="vendors/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Chart.js -->
<script src="vendors/Chart.js/dist/Chart.min.js"></script>
<!-- Custom Theme Scripts -->
<script>
$(document).ready(function(){
$.ajax({
url: "json/txpoolblock.json",
method: "GET",
dataType: "json",
success: function(data) {
txpoolarray = data;
}
})
$('#txhash').focus();
})
//Curency Support
$("#eur").click(function(){
location = location.origin + "/pendingTxReport.php?curr=eur";
});
$("#usd").click(function(){
location = location.origin + "/pendingTxReport?curr=usd";
});
$("#cny").click(function(){
location = location.origin + "/pendingTxReport?curr=cny";
});
$("#gbp").click(function(){
location = location.origin + "/pendingTxReport?curr=gbp";
});
$('#reset').click(function(){
$('#txhash').html("");
$('#bp').html("");
$('#blockswaiting').html("");
$('#meanBlocks').html("");
$('#minedprob').html("");
$('#gp').html("");
$('#go').html("");
$('#hp').html("");
$('#txatabove').html("");
$('#txEth').html("");
$('#txFiat').html("");
$('#txArgs').html("Pending Transaction Report:")
$('#txhash').focus();
})
function estimateWait (gasprice, gasoffered)
{
for(var i=0; i < txpoolarray.length; i++){
if (txpoolarray[i]['index'] == txhash){
hit = 1;
break;
}
else{
hit = 0;
}
}
if (hit){
return [txpoolarray[i]['block_posted'], txpoolarray[i]['gas_offered'], txpoolarray[i]['hashpower_accepting'], txpoolarray[i]['tx_atabove'], txpoolarray[i]['mined_probability'], txpoolarray[i]['gasprice'], txpoolarray[i]['expectedWait'], txpoolarray[i]['wait_blocks']];
}
else {
return ["", "", "", "", "", "", "", ""];
}
}
$('form').submit(function(event){
//Error Check
if(!$('#txhash').val()){
event.preventDefault(); // prevent form from POST to server
$('#txhash').focus();
focusSet = true;
return;
}
else {
txhash = $('#txhash').val();
}
//txhash set
event.preventDefault();
pdValues = estimateWait(txhash);
console.log(pdValues);
blockposted = pdValues[0];
gasoffered = pdValues[1];
hashpower = pdValues[2];
txatabove = pdValues[3];
minedprob = pdValues[4];
if (minedprob != ""){
minedprob = Number(pdValues[4].toFixed(2))*100;
}
gasprice = pdValues[5];
expectedWait = pdValues[6];
blocksWait = pdValues[7];
currency = '<?php echo ($currency) ?>';
console.log(currency);
exchangeRate =<?php echo ($exchangeRate) ?>;
blockInterval = <?php echo ($gpRecs2['block_time']) ?>;
txMeanSecs = blocksWait * blockInterval;
txMeanSecs = Number(txMeanSecs.toFixed(0))
txFeeEth = gasprice/1e9 * gasoffered;
txFeeEth = Number((txFeeEth).toFixed(7))
txFeeFiat = txFeeEth * exchangeRate;
txFeeFiat = Number(txFeeFiat.toFixed(5));
if (blockposted == ""){
blockposted = "Not Found";
txFeeEth = "";
txFeeFiat = "";
reportString = "<small><span style='color:red'> Not found: This tx may not bave been received by our node, it may have already been mined, or there may be another tx with a lower nonce pending from this account</small></span>";
$('#txArgs').html(reportString);
}
$('#bp').html(blockposted);
$('#hp').html(hashpower);
$('#gp').html(gasprice);
$('#blockswaiting').html(blocksWait);
$('#meanBlocks').html(expectedWait);
$('#txatabove').html(txatabove);
$('#minedprob').html(minedprob);
$('#go').html(gasoffered);
$('#txEth').html(txFeeEth);
if (blockposted == "Not Found"){
return;
}
if (currency=='usd'){
string="$"+txFeeFiat
$('#txFiat').html(string);
}
else if (currency=='eur'){
string="€"+txFeeFiat
$('#txFiat').html(string);
}
else if (currency=='cny'){
string="¥"+txFeeFiat
$('#txFiat').html(string);
}
else if (currency=='gbp'){
string="£"+txFeeFiat
$('#txFiat').html(string);
}
})
</script>
<script src="build/js/custom3.js"></script>
</body>
</html>