Skip to main content

Subscribe to live events

OmbraChain streams new blocks and transactions over Server-Sent Events (SSE) and WebSocket.

SSE (simplest)

const es = new EventSource("https://api.ombra-net.com/api/chain/events");

es.onmessage = (e) => {
const ev = JSON.parse(e.data);
// { type: "block", index, hash, proposer, txCount, timestamp }
// { type: "tx", txType, hash }
// { type: "hello", height } | { type: "ping" }
if (ev.type === "block") console.log("new block #" + ev.index);
};

SSE auto-reconnects in the browser. Use it for live dashboards, explorers, and notifications.

WebSocket

const ws = new WebSocket("wss://api.ombra-net.com/api/ws");
ws.onmessage = (e) => console.log(JSON.parse(e.data));

The SDK wraps this:

import { OmbraClient } from "@ombrachain/sdk";
const client = new OmbraClient({ endpoint: "https://api.ombra-net.com" });
const ws = client.ws();
ws.onBlock((b) => console.log("block", b.index));

Watching an account

To react to rewards or incoming transfers for a specific address, poll its recent transactions:

GET /api/chain/account/ox7a8b… → { balance, nonce, recentTxs: [...] }

Filter recentTxs for TASK_REWARD (mining income) or TRANSFER where to is your address.