* Add yarn-error.log to gitignore. * Add ts-node to devDependencies. Add script to only build tsc. Add websocket to keywords. * Update yarn.lock libs. * FIX websocket endpoint hostname. FIX corrent import for all examples. FIX websocket instrucions on readme.
28 lines
616 B
TypeScript
28 lines
616 B
TypeScript
import mempoolJS from "@mempool/mempool.js";
|
|
|
|
const { liquid: { websocket } } = mempoolJS();
|
|
|
|
const init = async () => {
|
|
|
|
const ws = websocket.initServer({
|
|
options: ["blocks", "stats", "mempool-blocks", "live-2h-chart"],
|
|
});
|
|
|
|
ws.on("message", function incoming(data) {
|
|
const res = JSON.parse(data.toString());
|
|
if (res.blocks) {
|
|
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);
|
|
}
|
|
});
|
|
}
|
|
init();
|