Add bisqJS and liquidJS npm modules.
This commit is contained in:
30
examples/nodejs/liquid-js/websocket.ts
Normal file
30
examples/nodejs/liquid-js/websocket.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import mempoolJS from "./../../../src/index";
|
||||
|
||||
const { liquid: { websocket } } = mempoolJS();
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
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);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
init();
|
||||
Reference in New Issue
Block a user