Skip to content

Commit 2b01b2d

Browse files
authored
Create Bitcoin mempool
1 parent 8211ef9 commit 2b01b2d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Diff for: Bitcoin mempool

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import mempoolJS from "@mempool/mempool.js";
2+
3+
const init = async () => {
4+
5+
const { bitcoin: { websocket } } = mempoolJS({
6+
hostname: 'mempool.space'
7+
});
8+
9+
const ws = websocket.initServer({
10+
options: ["blocks", "stats", "mempool-blocks", "live-2h-chart"],
11+
});
12+
13+
ws.on("message", function incoming(data) {
14+
const res = JSON.parse(data.toString());
15+
if (res.block) {
16+
console.log(res.block);
17+
}
18+
if (res.mempoolInfo) {
19+
console.log(res.mempoolInfo);
20+
}
21+
if (res.transactions) {
22+
console.log(res.transactions);
23+
}
24+
if (res["mempool-blocks"]) {
25+
console.log(res["mempool-blocks"]);
26+
}
27+
});
28+
29+
};
30+
31+
init();

0 commit comments

Comments
 (0)