telescope icon indicating copy to clipboard operation
telescope copied to clipboard

web socket client

Open pyramation opened this issue 2 years ago • 5 comments

reference implementations

  • https://github.com/atmoner/cosmos-websocket

pyramation avatar May 21 '22 17:05 pyramation

reference implementations

  • https://github.com/atmoner/cosmos-websocket

You can refer to this file for a minimum code, it simply retrieves the new blocks live from websocket of tendermint :+1:

import WebSocket from 'ws';
const ws = new WebSocket('ws://osmosis.strange.love:26657/websocket');

ws.on('open', function open() {
  console.log('Connected on Osmosis blockchain from WebSocket');
  ws.send(JSON.stringify({
    "method":"subscribe",
    "params": ["tm.event='NewBlock'"],
    "id":"1",
    "jsonrpc":"2.0"
  }));
});

ws.on('close', function close() {
  console.log('disconnected');
});
 
ws.on('message', function incoming(data) {
  var finalData = JSON.parse(data.toString('utf-8'));
  if (finalData.result.data)
    console.log(finalData.result);
}); 

https://github.com/atmoner/cosmos-websocket/blob/main/osmosis-websocket.js

image

The doc is here: https://docs.tendermint.com/master/rpc/

atmoner avatar May 22 '22 01:05 atmoner

thanks @atmoner ! this is much appreciated :)

pyramation avatar May 22 '22 23:05 pyramation

Also; keplr-wallet TendermentTxTracer

https://github.com/chainapsis/keplr-wallet/blob/97a65130583778b09e59016e0e7c95a296641c94/packages/cosmos/src/tx-tracer/index.ts#L9-L308

jonator avatar Nov 28 '22 16:11 jonator

@Zetazzz hey, do you want to discuss on how we will implement this ? I can't reach to you through discord so tagging you here.

hoangdv2429 avatar May 17 '23 09:05 hoangdv2429

@hoangdv2429 Hey, sorry for late response. yes, I think we can discuss more on discord.

Zetazzz avatar May 17 '23 13:05 Zetazzz