2021-04-08 10:15:30 -03:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Page Title</title>
|
2021-04-10 12:30:24 -03:00
|
|
|
<script
|
|
|
|
type="text/javascript"
|
|
|
|
src="https://mempool.space/mempool.js"
|
|
|
|
></script>
|
2021-04-08 10:15:30 -03:00
|
|
|
<script>
|
|
|
|
const init = async () => {
|
|
|
|
const { websocket } = mempoolJS();
|
|
|
|
|
|
|
|
const ws = await websocket.initClient({
|
|
|
|
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
|
|
|
|
});
|
|
|
|
|
|
|
|
ws.addEventListener('message', function incoming({ data }) {
|
|
|
|
const res = JSON.parse(data);
|
|
|
|
if (res.blocks) {
|
|
|
|
res.blocks.forEach((block) => {
|
|
|
|
console.log(block.height);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (res.mempoolInfo) {
|
|
|
|
console.log(res.mempoolInfo);
|
|
|
|
}
|
|
|
|
if (res.transactions) {
|
|
|
|
console.log(res.transactions);
|
|
|
|
}
|
|
|
|
if (res.mempoolBlocks) {
|
|
|
|
console.log(res.mempoolBlocks);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
init();
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body></body>
|
|
|
|
</html>
|