<body>
<div class="container pb-3 px-5">
<h1 class="text-center p-3 alert-info">
<a href="https://trustdice.win/crash" target="_blank" class="alert-link"> <u>TRUSTDICE.WIN</u></a> CRASH VERIFIER
</h1>
<div class="config">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text"><b>Game's Hash</b></span>
</div>
<input id="gameHash" type="text" spellcheck="false" class="form-control"
placeholder="Game's hash you want to validate">
</div>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text"><b>Game's Amount</b></span>
</div>
<input id="gameAmount" value="10" type="number" spellcheck="false" class="form-control"
placeholder="Amount of game to show from this hash">
</div>
<button type="button" class="btn btn-info btn-block btn-lg" onclick="verifyCrashPoint();">VERIFY CRASH POINT
</button>
</div>
<hr class="my-4">
<div class="result">
<table id="hashTable" class="table table-striped">
<thead>
<tr>
<th>Game's hash</th>
<th>Crash Point</th>
</tr>
</thead>
<tbody id="tbody"></tbody>
</table>
</div>
</div>
</body>
body {
background-color: #d1ecf1;
}
.config, .result {
padding: 20px 16px;
border-radius: 3px;
}
.config {
background: #90c2ea8c;
}
.config .input-group-text {
width: 150px;
}
.table thead th {
border-top: 1px solid rgba(0, 0, 0, 0.3);
border-bottom: 1px solid rgba(0, 0, 0, 0.3);
}
table {
border-collapse: collapse;
}
table, th, td {
border: 1px solid rgba(0, 0, 0, 0.3);
font-family: Consolas,"Courier New",Courier,FreeMono,monospace;
}
th, td {
padding: 5px;
}
th:first-child,
td:first-child {
min-width: 680px;
}
td:last-child{
font-weight: bold;
}
.red {
background: red;
}
.green {
background: green;
}
.blue {
background: blue;
}
// NOTE: For the 18th round crash game verification, please refer: https://codepen.io/trustdice/pen/XWQWPWZ
// The provably fair detail refer https://help.trustdice.win/collections/1988793-crash-game
// The block chain record refer https://bloks.io/transaction/1cfece40f451a0ebaf544922904c8bac762ddc82001bc9b50bc25b6f695eeb4a
// Block #359398000 Hash value: https://bloks.io/block/359398000
const salt = '156bfa7018202ca9fdd069aed6c3a7ecc5ba8eb6a4ca20120f7fde5adb916183';
let query = URI(document.location.search).search(true);
$("#gameHash").val(query.game_hash);
function verifyCrashPoint() {
let hash = $("#gameHash").val();
if (hash.length !== 64) {
alert("Please input valid game hash!");
return;
}
let lastHash = "";
let amount = $("#gameAmount").val();
let $tableBody = $("#tbody");
$tableBody.html("");
for (let i = 0; i < amount; i++) {
let gameHash = (lastHash !== "" ? genGameHash(lastHash) : hash);
let gameCrash = crashPointFromGameHash(gameHash);
let colorClass = gameCrash > 1.97 ? 'green' : (gameCrash < 1.97 ? 'red' : 'blue');
let newRow = "<tr><td>" + gameHash + "</td><td class='" + colorClass + "'>" + gameCrash + "</td></tr>";
$tableBody.append(newRow);
lastHash = gameHash;
}
}
function genGameHash(lastGameHash) {
return sha256(lastGameHash)
}
function crashPointFromGameHash(gameHash) {
let seed = gameHash;
let hash = sha256(seed + salt);
let h = parseInt(hash.slice(0, 13), 16);
let e = Math.pow(2, 52);
let result = Math.floor((96 * e) / (e - h));
if (result < 101) {
result = 0;
}
if (result > 10000000) {
result = 10000000
}
return (result / 100).toFixed(2);
}