WebSocket Events

BitBadges runs on a Cosmos SDK (CometBFT/Tendermint) blockchain, which exposes a standard WebSocket interface for subscribing to real-time events. This is useful for bots that need to react to on-chain activity like transfers, mints, and collection updates.

Connection

Network
WebSocket URL

Mainnet

wss://rpc.bitbadges.io/websocket

Testnet

wss://rpc-testnet.bitbadges.io/websocket

These are standard CometBFT JSON-RPC WebSocket endpoints.

Subscribe Method

Use the subscribe JSON-RPC method with a Tendermint event query:

{
  "jsonrpc": "2.0",
  "method": "subscribe",
  "id": 1,
  "params": {
    "query": "tm.event='Tx'"
  }
}

Common Queries for Bots

All Transactions

New Blocks

Transactions by Message Type

Subscribe to specific message types (e.g., transfers):

Transactions by Sender

Combining Filters

Common BitBadges Message Types

Message Type
Action String

Transfer tokens

/badges.MsgTransferTokens

Create collection

/badges.MsgCreateCollection

Update collection

/badges.MsgUpdateCollection

Delete collection

/badges.MsgDeleteCollection

Update user approvals

/badges.MsgUpdateUserApprovals

Create address lists

/badges.MsgCreateAddressLists

Working Example (Node.js)

Install the ws package:

Unsubscribe

To stop receiving events:

Or unsubscribe from all:

Notes

  • Event attributes are base64-encoded in CometBFT responses. Use atob() (or Buffer.from(str, 'base64').toString()) to decode.

  • The WebSocket connection may drop due to network issues. Implement reconnection logic with exponential backoff for production bots.

  • The internal BitBadges indexer WebSocket (activity feeds, candlestick data) is not publicly exposed. Use the REST API for indexed data.

  • For querying historical data, use the BitBadges API instead of WebSocket events.

Last updated