41 lines
1.0 KiB
HTML
Raw Normal View History

2021-08-10 01:30:13 -03:00
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="./../../../../dist/mempool.js"></script>
<script>
const init = async () => {
try {
const {
bitcoin: { websocket },
} = mempoolJS();
const ws = websocket.initClient({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
ws.addEventListener('message', function incoming({data}) {
const res = JSON.parse(data.toString());
2021-11-02 17:15:01 +01:00
if (res.block) {
2021-08-10 01:30:13 -03:00
console.log(res.blocks);
}
if (res.mempoolInfo) {
console.log(res.mempoolInfo);
}
if (res.transactions) {
console.log(res.transactions);
}
if (res.mempoolBlocks) {
console.log(res.mempoolBlocks);
}
});
} catch (error) {
console.log(error);
}
};
init();
</script>
</head>
<body></body>
</html>