-
Notifications
You must be signed in to change notification settings - Fork 0
/
mempool.html
63 lines (61 loc) · 2.03 KB
/
mempool.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
<!DOCTYPE html>
<html>
<head>
<!-- CSS -->
<link rel="stylesheet" href="css/bulma.min.css" />
<link rel="stylesheet" href="css/main.css" />
<!-- Lightning -->
<meta name="lightning" content="[email protected]" />
</head>
<body class="has-background-light">
<section class="section">
<div class="container">
<h1 class="title">Stats from mempool</h1>
<h2>Blocks</h2>
<pre id="result-blocks">Waiting for data</pre>
<br />
<h2>Mempool Info</h2>
<pre id="result-mempool-info">Waiting for data</pre>
<br />
<h2>Transactions</h2>
<pre id="result-transactions">Waiting for data</pre>
<br />
<h2>Mempool Blocks</h2>
<pre id="result-mempool-blocks">Waiting for data</pre>
</div>
</section>
<script src="https://mempool.space/mempool.js"></script>
<script>
const init = async () => {
const {
bitcoin: { websocket },
} = mempoolJS({
hostname: 'mempool.space',
})
const ws = websocket.initClient({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
})
ws.addEventListener('message', function incoming({ data }) {
const res = JSON.parse(data.toString())
if (res.block) {
document.getElementById('result-blocks').textContent =
JSON.stringify(res.block, undefined, 2)
}
if (res.mempoolInfo) {
document.getElementById('result-mempool-info').textContent =
JSON.stringify(res.mempoolInfo, undefined, 2)
}
if (res.transactions) {
document.getElementById('result-transactions').textContent =
JSON.stringify(res.transactions, undefined, 2)
}
if (res['mempool-blocks']) {
document.getElementById('result-mempool-blocks').textContent =
JSON.stringify(res['mempool-blocks'], undefined, 2)
}
})
}
init()
</script>
</body>
</html>