cosmjs
cosmjs copied to clipboard
EVENT SUBSCRIBE
How can i subscribe to events with the help of cosmjs.
i wish this question had an answer
Hi @Abhishek-1857 , I managed to subscribe to the new block event using: ` const ws_client = new WebsocketClient(ws_tm_tendermint_rpc, (err)=>{console.log("Error Connecting:", err)}) const tm_client = Tendermint34Client.create(ws_client);
var new_block_subscribe = (await tm_client).subscribeNewBlock();
var latestUpdate = {};
var readLatestUpdate = true;
new_block_subscribe.addListener(
{
next: i => {console.log(i); latestUpdate = i; readLatestUpdate = false;},
error: err => console.error(err),
complete: () => console.log('completed'),
});`
Still trying to understand how to subscribe to other events similar to {"query":"tm.event = 'NewBlock'"}} using subscribeTx, but there is zero documentation on this topic
Ok, they wont allow you to query anything else than tm.event = "Tx" AND etc.. idk why they would limit it this way,.
@ranlavanet can you share with me a example for this ?