Skip to main content

Real-time events — follow blocks, balances and transactions over WebSocket

· 4 min read

The ChainGate API can now push events to you as they happen. Open a single WebSocket connection, subscribe to the addresses and channels you care about, and receive new blocks, balance changes, transaction activity and pending transactions the moment they land — no polling loops, no block scanning, no third-party webhook service.

Events are available today on Bitcoin, Litecoin, Dogecoin, Bitcoin Cash, Bitcoin Testnet, Ethereum and Avalanche, and they are included with the free API key.

One connection, every event you care about​

There are two families of endpoints, one for UTXO chains and one for EVM chains. Both speak the same protocol:

wss://api.chaingate.dev/utxo/{network}/events?api_key=YOUR_API_KEY
wss://api.chaingate.dev/evm/{network}/events?api_key=YOUR_API_KEY
Family{network}
UTXObitcoin, bitcoincash, litecoin, dogecoin, bitcointestnet
EVMethereum, avalanche

The API key travels as a query parameter, exactly like the RPC endpoints, so the streams work straight from the browser — no extra headers.

Subscribe in a few lines​

// Browser, or Node with the `ws` package
const ws = new WebSocket('wss://api.chaingate.dev/evm/ethereum/events?api_key=YOUR_API_KEY')

ws.onopen = () => {
// Every new block
ws.send(JSON.stringify({ action: 'subscribe', channel: 'blocks' }))
// The confirmed balance of an address, after every block that touches it
ws.send(JSON.stringify({ action: 'subscribe', channel: 'balance', address: '0xa1b2c3...abc' }))
}

ws.onmessage = (msg) => {
const event = JSON.parse(msg.data)
if (event.type === 'balance') console.log(event.address, '→', event.confirmedWei, 'wei')
}

One connection can hold as many subscriptions as you need, across channels and addresses. Every subscribe is acknowledged, and a bad request is answered with an error frame while your other subscriptions keep flowing.

Channels​

ChannelAddress?FlagsWhat you receive
blocksNofullNew block summaries — or the entire block with full: true.
balanceYespendingThe confirmed balance — or the pending delta with pending: true.
historyYespendingConfirmed transaction activity — or the address's pending transactions with pending: true.
mempoolNo—Every pending transaction, as it is seen.
contract_interactionsYes—New contracts an address interacts with. (EVM only.)

Confirmed and pending data share a channel: subscribe to balance for the confirmed balance, or add pending: true to follow the mempool instead — there is no second channel name to remember. The same applies to history, and to blocks with full: true.

{ "action": "subscribe", "channel": "balance", "address": "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4", "pending": true }

Same field names as the REST API​

Events use the field names you already know from the REST endpoints — height, confirmedSat / confirmedWei, addressBalance, txid — so a balance you receive over the stream drops straight into the same code that reads it over HTTP:

{ "type": "balance", "address": "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4", "confirmedSat": "12395678" }
{
"type": "history",
"data": { "address": "0xa1b2c3...abc", "height": 19234567, "block_n": 42 }
}

Amounts are strings in the smallest unit (satoshis on UTXO chains, wei on EVM chains), events are emitted after a block is finalized, and within a block you always get the block event first and the per-address events after it — so a follow-up REST read already reflects what an event just told you.

Built for long-lived connections​

  • The server pings every 30 seconds and drops a connection that stays silent for 75 seconds; standard WebSocket clients answer automatically, and you can send { "action": "ping" } yourself from the browser.
  • If a connection ever drops, reconnect, re-send your subscriptions and re-read current state through the REST API to catch up.

Highlights​

FeatureDescription
WebSocket event streamswss://api.chaingate.dev/utxo/{network}/events and /evm/{network}/events
7 networksBitcoin, Litecoin, Dogecoin, Bitcoin Cash, Bitcoin Testnet, Ethereum, Avalanche
blocksBlock summaries, or full blocks with full: true
balance / historyConfirmed by default, pending with pending: true
mempoolEvery pending transaction as it is seen
contract_interactionsNew (address, contract) pairs on EVM chains
Free tierIncluded with every API key

Head over to the Events documentation for the full protocol, the per-network event formats and a reconnect recipe, and grab your free API key at ChainGate's Dashboard.

Star us on GitHub and join the Discord to tell us what you're building.