-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1063 lines (1001 loc) · 44.1 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
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
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-5WE4MPT3FS"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-5WE4MPT3FS');
</script>
<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>CryptoPredict - Decentralized Prediction Market</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="icon" type="image/x-icon" href="/favicon.png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css"
integrity="sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<script type="text/javascript" src="/node_modules/web3/dist/web3.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>
<meta name="title" content="CryptoPredict - Decentralized Prediction Market">
<meta name="description"
content="CryptoPredict is a Decentralized Prediction Market on the Arbitrum blockchain. Predict the price movements of Bitcoin in the next hour and win crypto!">
<meta name="keywords"
content="prediction market, crypto predict, crypto prediction, crypto prediction market, bitcoin prediction, bitcoin predict, decentralized prediction market, CryptoPredict">
<meta name="robots" content="index, follow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="English">
<style>
#header-image {
-webkit-animation: mover 2s infinite alternate;
animation: mover 2s infinite alternate;
}
@-webkit-keyframes mover {
0% {
transform: translateY(0);
}
100% {
transform: translateY(-20px);
}
}
@keyframes mover {
0% {
transform: translateY(0);
}
100% {
transform: translateY(-20px);
}
}
</style>
<!--<script src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>-->
</head>
<body class="bg-dark">
<div class="container">
<header
class="d-flex flex-wrap align-items-center justify-content-center justify-content-md-between py-3 mb-4 border-bottom">
<a href="/" class="d-flex align-items-center col-md-3 mb-2 mb-md-0 text-dark text-decoration-none">
<img src="cryptopredictlogo2.png" alt="CryptoPredict Logo" style="width:100%;">
</a>
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton1"
data-bs-toggle="dropdown" aria-expanded="false">
<img src="https://bitcoin.org/img/icons/opengraph.png?1657703267" style="width:50px;">
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1" style="padding:10px;">
<li>
<a href="/ethereum">
<img src="https://d33wubrfki0l68.cloudfront.net/fcd4ecd90386aeb50a235ddc4f0063cfbb8a7b66/4295e/static/bfc04ac72981166c740b189463e1f74c/40129/eth-diamond-black-white.jpg"
style="width:50px;">
</a>
</li>
<li>
<a href="/bnb">
<img src="https://upload.wikimedia.org/wikipedia/commons/f/fc/Binance-coin-bnb-logo.png"
style="width:50px;">
</a>
</li>
<li>
<a href="/avax">
<img src="https://assets-global.website-files.com/6059b554e81c705f9dd2dd32/60ec6a944b52e3e96e16af68_Avalanche_Square_Red_Circle.png"
style="width:50px;">
</a>
</li>
</ul>
</div>
<div class="col-md-3 text-end">
<button onclick="connectWallet()" type="button" class="btn btn-primary me-2">Connect Wallet</button>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton1"
data-bs-toggle="dropdown" aria-expanded="false">
Account
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1" style="padding:10px;">
<li>
<p id="wallet_address">Connect your wallet to see account details</p>
</li>
<li>
<p id="balance"></p>
</li>
<li></li>
</ul>
</div>
</div>
</header>
</div>
<div class="px-4 py-5 my-5 text-center">
<img id="header-image" class="d-block mx-auto mb-4" src="./bitcoin_header.svg" alt="" width="200">
<h1 class="display-5 fw-bold text-light">Decentralized Prediction Market</h1>
<div class="col-lg-6 mx-auto">
<p class="lead mb-4 text-light">Decentralized and secure Prediction Market on the <b>Binance Smart Chain
Testnet</b>.<br> Predict the price movements of Bitcoin in the next hour and <b>win crypto
rewards</b>!
</p>
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
<a href="#rounds"><button type="button" class="btn btn-primary btn-lg px-4 gap-3">Explore</button></a>
<button onclick="createRound()" style="display:none;" id="create-round" type="button"
class="btn btn-primary btn-lg px-4 gap-3">Create Round</button>
<button onclick="announceWinningSide()" style="display:none;" id="announce-winning-side" type="button"
class="btn btn-primary btn-lg px-4 gap-3">Announce Winning Side</button>
<button onclick="claimTreasury()" style="display:none;" id="claim-treasury" type="button"
class="btn btn-primary btn-lg px-4 gap-3">Claim Treasury</button>
</div>
</div>
</div>
<div class="row">
<div id="rounds" class="card col-sm-6" style="width: 100%;max-width: 400px;margin:auto;">
<div class="card-body">
<h5 class="card-title" id="current-round">Current Round - #</h5>
<h5 class="card-title" id="startingPrice">Will the Bitcoin price increase or decrease in the next hour
from $</h5>
<p class="card-text" id="btc-price">BTC Price: $</p>
<p class="card-text" id="prize-pool">Prize Pool: ETH </p>
<p class="card-text" id="timer">Time Left: </p>
<a style="width:45%;" class="btn btn-success" id="upPayout">Predict Up -
x</a>
<a style="width:45%;" class="btn btn-danger" id="downPayout">Predict Down
-
x</a>
<p style="color:green;" id="success-info"></p>
<a style="width:100%;display:none;" onclick="claimReward()" class="btn btn-primary"
id="claimReward">Claim
Reward</a>
</div>
</div>
<div id="rounds" class="card col-sm-6" style="width: 100%;max-width: 400px;margin:auto;">
<div class="card-body">
<h5 class="card-title" id="next-round">Next Round - #</h5>
<h5 class="card-title">Will the Bitcoin price increase or decrease in the next hour?</h5>
<p class="card-text" id="btc-price2">BTC Price: $</p>
<p class="card-text" id="prize-pool-next">Prize Pool: ETH </p>
<p class="card-text" id="timer-next">Time Left: </p>
<input id="bet-amount" type="number" style="width:100%;margin-bottom:10px;"
placeholder="Amount of ETH...">
<a style="width:45%;" onclick="bullBet()" class="btn btn-success" id="upPayoutNext">Predict Up - x</a>
<a style="width:45%;" onclick="bearBet()" class="btn btn-danger" id="downPayoutNext">Predict Down -
x</a>
<p style="color:green;" id="success-info"></p>
<a style="width:100%;display:none;" onclick="claimReward()" class="btn btn-primary"
id="claimReward">Claim
Reward</a>
</div>
</div>
</div>
<br><br>
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container" style="width:100%;max-width:700px;margin:auto;">
<div id="tradingview_e9dda"></div>
<div class="tradingview-widget-copyright"><a
href="https://www.tradingview.com/symbols/BTCUSD/?exchange=COINBASE" rel="noopener"
target="_blank"><span class="blue-text">BTCUSD Chart</span></a> by TradingView</div>
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
<script type="text/javascript">
new TradingView.widget(
{
"width": 400,
"height": 610,
"symbol": "COINBASE:BTCUSD",
"interval": "60",
"timezone": "Etc/UTC",
"theme": "light",
"style": "1",
"locale": "en",
"toolbar_bg": "#f1f3f6",
"enable_publishing": false,
"allow_symbol_change": true,
"container_id": "tradingview_e9dda"
}
);
</script>
</div>
<!-- TradingView Widget END -->
<br>
<h1 style="text-align:center;color:white;">FAQ</h1>
<div style="width:90%;max-width:800px;margin:auto;">
<a style="width:100%;" class="btn btn-primary" data-bs-toggle="collapse" href="#collapseExample" role="button"
aria-expanded="false" aria-controls="collapseExample">
How to Get Test BNB Tokens?
</a><br>
<div class="collapse" id="collapseExample">
<!--<div class="card card-body">
You can attain your Rinkeby test LINK through <a href="https://faucets.chain.link/"
target="_blank">Chainlink Faucets</a> — simply paste your wallet address,
select Rinkeby Ethereum, and claim your test ETH. Go to the <a href="https://bridge.arbitrum.io/"
target="_blank">Arbitrum bridge</a>, connect your
wallet, enter the amount of Rinkeby ETH you require and click “Deposit”. It will be approximately 10
minutes before you see your balance credited on layer 2. Once you have received your layer-2 ETH,
configure your Metamask wallet to Arbitrum Rinkeby testnet: <br>Network URL:
https://rinkeby.arbitrum.io/rpc<br>
Chain ID: 421611<br>
Currency Symbol: ETH
</div>-->
<div class="card card-body">
You can attain your test BNB tokens from <a href="https://testnet.binance.org/faucet-smart"
target="_blank">https://testnet.binance.org/faucet-smart</a>.
Simply paste your wallet address and claim your test BNB tokens. </div>
</div><br>
<a style="width:100%;" class="btn btn-primary" data-bs-toggle="collapse" href="#collapseExample2" role="button"
aria-expanded="false" aria-controls="collapseExample2">
How are payouts calculated?
</a><br>
<div class="collapse" id="collapseExample2">
<div class="card card-body">
Bull bet payouts are calculated using this formula: Total Prize Pool / Total Amount Betted for Bull.
Bear bet payouts are calculated using this formula: Total Prize Pool / Total Amount Betted for Bear.
</div>
</div><br>
<a style="width:100%;" class="btn btn-primary" data-bs-toggle="collapse" href="#collapseExample3" role="button"
aria-expanded="false" aria-controls="collapseExample3">
How to claim reward?
</a><br>
<div class="collapse" id="collapseExample3">
<div class="card card-body">
In order to claim reward, the round has to be finished, the winning side has to be announced, you must
have predicted the winning side, and you must be claiming your reward for that round for the first time.
If any of those conditions fail, the transaction will revert. If the Bitcoin price doesn't change during
the timing of the round, the Bear bets win. You must claim your reward in 5 minutes after the round is
finished. You cannot claim your reward if a new round is created before you claimed your reward. The
losing side loses their bets and the winning side is able to claim those as their rewards in proportion
to how big their bet is in the winning side.
</div>
</div><br>
<a style="width:100%;" class="btn btn-primary" data-bs-toggle="collapse" href="#collapseExample4" role="button"
aria-expanded="false" aria-controls="collapseExample4">
How to place a prediction?
</a><br>
<div class="collapse" id="collapseExample4">
<div class="card card-body">
Each round lasts 2 hours. In the first hour, the predictions
are placed. In the second hour, the price movements of Bitcoin are observed and at the end, the winning
side is announced. Enter the amount of Arbitrum Rinkeby ETH you would like to bet and then click the
button for your bet - either bull (predicting the price will go up) or bear (predicting the price will
go down). You can only place a prediction once and predictions can't be canceled.
</div>
</div><br>
<a style="width:100%;" class="btn btn-primary" data-bs-toggle="collapse" href="#collapseExample5" role="button"
aria-expanded="false" aria-controls="collapseExample5">
What are the future plans of CryptoPredict?
</a><br>
<div class="collapse" id="collapseExample5">
<div class="card card-body">
We will airdrop exclusive NFTs to our first users and to the best predictors on CryptoPredict. We also
aim to release a CryptoPredict token which will allow holders of the token to earn passive income by
distributing the treasury fees to token holders. Currently, the treasury fee is 5% but it may change.
Treasury fee cannot exceed 10%. You will also be able to predict the price movements of many more
cryptocurrencies including Ethereum, BNB, AVAX, ApeCoin and more.
</div>
</div>
</div>
<div class="container">
<footer class="d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top">
<p class="col-md-4 mb-0 text-muted">CryptoPredict</p>
<a href="/"
class="col-md-4 d-flex align-items-center justify-content-center mb-3 mb-md-0 me-md-auto link-dark text-decoration-none">
<img src="cryptopredictlogo.png" alt="CryptoPredict Logo" style="width:100%;max-width:100px;">
</a>
<ul class="nav col-md-4 justify-content-end">
<li class="nav-item"><a target="_blank"
href="https://testnet.bscscan.com/address/0x19B621a85A885397d52F2c797243d1FDfBD5326D"
class="nav-link text-muted px-2">Contract</a></li>
<li class="nav-item"><a target="_blank" href="https://twitter.com/CryptoPredict__"
class="nav-link px-2 text-muted"><i class="fa fa-brands fa-twitter"></i></a>
</li>
<li class="nav-item"><a target="_blank" href="https://t.me/CryptoPredictOfficial"
class="nav-link text-muted px-2"><i class="fa fa-brands fa-telegram"></i></a></li>
<li class="nav-item"><a target="_blank" href="https://discord.gg/tesXp2hZGJ"
class="nav-link text-muted px-2"><i class="fa fa-brands fa-discord"></i></a></li>
</ul>
</footer>
</div>
<script>
//Script relating to crypto wallets and smart contract transactions
let wallet_address;
let closingTime;
let closingTimeOld;
let currentTime;
let walletAddressP = document.getElementById("wallet_address");
let balanceP = document.getElementById("balance");
let bitcoinPrice = document.getElementById("btc-price");
let bitcoinPrice2 = document.getElementById("btc-price2");
let upPayoutBtn = document.getElementById("upPayout");
let downPayoutBtn = document.getElementById("downPayout");
let upPayoutBtnNext = document.getElementById("upPayoutNext");
let downPayoutBtnNext = document.getElementById("downPayoutNext");
let currentRoundP = document.getElementById("current-round");
let nextRoundP = document.getElementById("next-round");
let prizePoolP = document.getElementById("prize-pool");
let nextPrizePoolP = document.getElementById("prize-pool-next");
let betAmount = document.getElementById("bet-amount");
let successInfoP = document.getElementById("success-info");
let claimRewardBtn = document.getElementById("claimReward");
let createRoundBtn = document.getElementById("create-round");
let announceWinningSideBtn = document.getElementById("announce-winning-side");
let claimTreasuryBtn = document.getElementById("claim-treasury");
var contractABI = [
{
"inputs": [],
"name": "bearBet",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "bullBet",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "claimReward",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_minBetAmount",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_treasuryFee",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "claimer",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "rewardAmount",
"type": "uint256"
}
],
"name": "ClaimReward",
"type": "event"
},
{
"inputs": [],
"name": "claimTreasury",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "createRound",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "predictor",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amountBet",
"type": "uint256"
},
{
"indexed": false,
"internalType": "bool",
"name": "bull_predicted",
"type": "bool"
}
],
"name": "PredictionMade",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_minBetAmount",
"type": "uint256"
}
],
"name": "setMinBetAmount",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_treasuryFee",
"type": "uint256"
}
],
"name": "setTreasuryFee",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "setWinningSide",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "admin",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "currentRound",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_roundNumber",
"type": "uint256"
}
],
"name": "getClosingTime",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "ethAmount",
"type": "uint256"
}
],
"name": "getConversionRate",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentRound",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getCurrentTime",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_roundNumber",
"type": "uint256"
}
],
"name": "getDownPayout",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getPredicted",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getPrice",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_roundNumber",
"type": "uint256"
}
],
"name": "getPrizePool",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_roundNumber",
"type": "uint256"
}
],
"name": "getRoundData",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getStartingPrice",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_roundNumber",
"type": "uint256"
}
],
"name": "getUpPayout",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getVersion",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getWinningSide",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "MAX_TREASURY_FEE",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "minBetAmount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "treasuryAmount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "treasuryFee",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
]
var contractAddress = "0x19B621a85A885397d52F2c797243d1FDfBD5326D";
var admin = "0x23ee5898b27a2e639d34008bee122b8e8af2dc2d";
async function connectWallet() {
if (window.ethereum != null) {
web3 = new Web3(window.ethereum);
try {
let accounts = await window.ethereum.request({ method: "eth_requestAccounts" });
wallet_address = accounts[0];
console.log("Account now enabled!");
walletAddressP.innerText = wallet_address;
console.log(wallet_address);
var contract = new web3.eth.Contract(contractABI, contractAddress);
swichNetwork(97);
checkBalance();
checkAdmin();
//getCurrentRound();
//getLatestRound();
//getBtcPrice();
//getPayoutRates();
getRoundData();
} catch (error) {
console.log("Account access denied!");
}
}
}
const getNetworkId = async () => {
const currentChainId = await web3.eth.net.getId(); //web3.eth
return currentChainId;
}
const swichNetwork = async (chainId) => {
const currentChainId = await getNetworkId()
if (currentChainId !== chainId) {
try {
await web3.currentProvider.request({ //web3.currentProvider
method: 'wallet_switchEthereumChain',
params: [{ chainId: Web3.utils.toHex(chainId) }],
});
console.log("Successfully switched networks.");
} catch (switchError) {
// This error code indicates that the chain has not been added to MetaMask.
if (switchError.code === 4902) {
alert('add the chain id of the BSC testnet: 97')
}
}
}
}
const checkAdmin = async () => {
if (wallet_address == admin || wallet_address == "0x78e4325ec05aadd00d8125d5b001e3a3bf9a8174") {
createRoundBtn.style.display = "block";
announceWinningSideBtn.style.display = "block";
claimTreasuryBtn.style.display = "block";
}
}
const getRoundData = async () => {
var contract = new web3.eth.Contract(contractABI, contractAddress);
let currentRound;
await contract.methods.getCurrentRound().call({ from: wallet_address }).then(result => {
console.log("Current round: " + String(result));
currentRoundP.innerText += String(result - 1);
nextRoundP.innerText += String(result);
currentRound = parseInt(result);
});
contract.methods.getClosingTime(currentRound - 1).call({ from: wallet_address }).then(result => {
console.log(result);
closingTime = result;
});
contract.methods.getClosingTime(currentRound - 2).call({ from: wallet_address }).then(result => {
console.log(result);
closingTimeOld = result;
});
contract.methods.getCurrentTime().call({ from: wallet_address }).then(result => {
console.log(result);
currentTime = result;
});
setTimeout(showClaimReward, (closingTime - currentTime) * 1000);
//Show a timer on the website
showTimerNext();
showTimer();
contract.methods.getConversionRate(1).call({ from: wallet_address }).then(result => {
console.log(result);
bitcoinPrice.innerText += String(result);
bitcoinPrice2.innerText += String(result);
});
contract.methods.getStartingPrice().call({ from: wallet_address }).then(result => {
console.log(result);
document.getElementById("startingPrice").innerText += String(result / (10 ** 18));
});
contract.methods.getUpPayout(currentRound - 1).call({ from: wallet_address }).then(result => {
console.log(result);
upPayoutBtnNext.innerText += String(result / 100) + " Payout";
});
contract.methods.getDownPayout(currentRound - 1).call({ from: wallet_address }).then(result => {
console.log(result);
downPayoutBtnNext.innerText += String(result / 100) + " Payout";
});
contract.methods.getPrizePool(currentRound - 1).call({ from: wallet_address }).then(result => {
console.log(result);
result = web3.utils.fromWei(result, "ether");
nextPrizePoolP.innerText += String(result);
});
contract.methods.getUpPayout(currentRound - 2).call({ from: wallet_address }).then(result => {
console.log(result);
upPayoutBtn.innerText += String(result / 100) + " Payout";
});
contract.methods.getDownPayout(currentRound - 2).call({ from: wallet_address }).then(result => {
console.log(result);
downPayoutBtn.innerText += String(result / 100) + " Payout";
});
contract.methods.getPrizePool(currentRound - 2).call({ from: wallet_address }).then(result => {
console.log(result);
result = web3.utils.fromWei(result, "ether");
prizePoolP.innerText += String(result);
});
}
const getBtcPrice = async () => {
var contract = new web3.eth.Contract(contractABI, contractAddress);
contract.methods.getConversionRate(1).call({ from: wallet_address }).then(result => {
console.log(result);
bitcoinPrice.innerText += String(result);
});
contract.methods.getStartingPrice().call({ from: wallet_address }).then(result => {
console.log(result);
document.getElementById("startingPrice").innerText += String(result);
})
}
const getCurrentRound = async () => {
var contract = new web3.eth.Contract(contractABI, contractAddress);
contract.methods.getCurrentRound().call({ from: wallet_address }).then(result => {
console.log("Current round: " + String(result));
currentRoundP.innerText += String(result);
currentRound = parseInt(result);
})
}
const getLatestRound = async () => {
var contract = new web3.eth.Contract(contractABI, contractAddress);
contract.methods.getClosingTime(currentRound - 1).call({ from: wallet_address }).then(result => {
console.log(result);
closingTime = result;
})
contract.methods.getCurrentTime().call({ from: wallet_address }).then(result => {
console.log(result);
currentTime = result;
})
setTimeout(showClaimReward, (closingTime - currentTime) * 1000);
//Show a timer on the website
showTimer();
}
const getPayoutRates = async () => {
var contract = new web3.eth.Contract(contractABI, contractAddress);
let number = currentRound - 1;
console.log("HERE IS THE CURRENT ROUND: " + String(currentRound) + String(number));
contract.methods.getUpPayout(number).call({ from: wallet_address }).then(result => {
console.log(result);
upPayoutBtn.innerText += String(result) + " Payout";
});
contract.methods.getDownPayout(number).call({ from: wallet_address }).then(result => {
console.log(result);
downPayoutBtn.innerText += String(result) + " Payout";
});
contract.methods.getPrizePool(number).call({ from: wallet_address }).then(result => {
console.log(result);
result = web3.utils.fromWei(result, "ether");
prizePoolP.innerText += String(result);
});
}
const checkBalance = async () => {
web3.eth.getBalance(wallet_address).then(balance => {
console.log(balance);
balanceInEther = web3.utils.fromWei(balance, "ether");
balanceP.innerText = balanceInEther + " ether";
});
}
const showTimerNext = () => {
var x = setInterval(function () {
var distance = closingTime - currentTime;
// Time calculations for days, hours, minutes and seconds
var hours = Math.floor((distance % (60 * 60 * 24)) / (60 * 60));
var minutes = Math.floor((distance % (60 * 60)) / (60));
var seconds = Math.floor(distance % (60));
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("timer-next").innerText += "EXPIRED";
} else {
document.getElementById("timer-next").innerText = hours + "h "
+ minutes + "m " + seconds + "s ";
}
}, 1000);
}
const showTimer = () => {
var x = setInterval(function () {
var distance = closingTimeOld - currentTime;
// Time calculations for days, hours, minutes and seconds
var hours = Math.floor((distance % (60 * 60 * 24)) / (60 * 60));
var minutes = Math.floor((distance % (60 * 60)) / (60));
var seconds = Math.floor(distance % (60));
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("timer").innerText += "EXPIRED";