Skip to content

Commit

Permalink
Wen 2.5 Activation —> 839444
Browse files Browse the repository at this point in the history
  • Loading branch information
saralab committed Apr 3, 2024
1 parent 7d8b4c3 commit 903a028
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions 2.5/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<script>
const HEIGHT_2_5 = 839444;
async function main() {
const current = await (await fetch("https://api.blockcypher.com/v1/btc/main")).json();
const current_height = current.height;
const current_date = new Date(current.time);

if (current_height >= HEIGHT_2_5) {
document.getElementById("main").innerHTML = `Stacks 2.5 epoch height reached!`;
} else {
let approximation_height = current_height - (HEIGHT_2_5 - current_height);
const prior = await (await fetch(`https://api.blockcypher.com/v1/btc/main/blocks/${approximation_height}?txstart=1&limit=1`)).json();
const prior_date = new Date(prior.time);

let second_approximation_height = current_height - 4 * (HEIGHT_2_5 - current_height);
const second_prior = await (await fetch(`https://api.blockcypher.com/v1/btc/main/blocks/${second_approximation_height}?txstart=1&limit=1`)).json();
const second_prior_date = new Date(second_prior.time);

const seconds_delta = current_date - prior_date;
const second_seconds_delta = (current_date - second_prior_date)/4;
const expected_seconds_delta = (seconds_delta + second_seconds_delta) / 2;

const expected_date = new Date(current_date.getTime() + expected_seconds_delta);

document.getElementById("block_target").innerHTML = `<b>${HEIGHT_2_5}</b>`;
document.getElementById("current_block").innerHTML = `<b>${current_height}</b>`;
document.getElementById("expected_date").innerHTML = `<b>${expected_date}</b>`;
document.getElementById("blocks_to_go").innerHTML = `<b>${HEIGHT_2_5 - current_height}</b>`;
document.getElementById("used_block").innerHTML = `<b>${approximation_height}</b>`;
document.getElementById("used_block_time").innerHTML = `<b>${prior_date}</b>`;
document.getElementById("time_ago").innerHTML = `<b>${Math.floor(seconds_delta / 3600.0 / 10)/ 100.0}</b>`;
}
}
main();
</script>
<h1>Wen 2.5 activate?</h1>
<div id="main">
<p>Current block is <span id="current_block"></span>.</p>
<p>A first-order estimation of 2.5 epoch start is: <span id="expected_date"></span>.</p>
<p></p>
<p>Stacks 2.5 epoch start (bitcoin block <span id="block_target"></span>) is <span id="blocks_to_go"></span> blocks away.</p>
<p></p>
<p>That many blocks ago was height = <span id="used_block"></span> which occured at <span id="used_block_time"></span>, <span id="time_ago"></span> hours ago.</p>
</div>

0 comments on commit 903a028

Please sign in to comment.