<>ts-stack
Get StartedArchitecturePackagesSpecsGuides
⌘K
Reference
Home
Get StartedOverviewInstallChoose your stackKey concepts
ArchitectureOverviewStack layersBEEF (BRC-62)BRC-100 Wallet InterfaceIdentity & AuthConformance pipeline
PackagesOverviewSDKWalletNetwork
@bsv/teranode-listener
OverlaysMessagingMiddlewareHelpers
InfrastructureOverviewmessage-box-serveroverlay-serveruhrp-server-basicuhrp-server-cloud-bucketwabwallet-infrachaintracks-server
SpecsOverviewBRC-100 Wallet InterfaceOverlay HTTPMessage-box HTTPAuthsocket (WebSocket)BRC-31 Auth HandshakeBRC-29 Peer PaymentBRC-121 / HTTP 402ARC BroadcastMerkle ServiceStorage AdapterGASP SyncUHRPAir-Gap Optical (BRC-141)
ConformanceOverviewVector catalogTS runnerContributing vectors
GuidesOverviewBuild a wallet-aware appRun an overlay nodePeer-to-peer messagingHTTP 402 payments
ReferenceOverviewBRC indexRepository health
AboutVersioningContributingDoc agentDocumentation sources
Loading…
Edit this page on GitHub
© 2026 BSV Blockchain. ts-stack is open-source.
GitHubContributingVersioning

Network

Connect to Teranode via private DHT and subscribe to real-time blockchain events (blocks, subtrees, mining updates).

Packages in this Domain

PackagePurpose
@bsv/teranode-listenerSubscribe to Teranode P2P topics via libp2p private DHT with gossipsub pub/sub messaging

What You Can Do

  • Listen for new blocks — Real-time block solution events from Teranode
  • Monitor subtree updates — Track subtree creation and validation
  • Track mining status — Subscribe to mining enabled/disabled events
  • Monitor peer connections — Handshake messages from connecting peers
  • Detect rejected transactions — Receive txid of transactions rejected by network
  • Custom topic subscription — Dynamic add/remove of topic callbacks at runtime
  • Private DHT participation — Join closed, authenticated peer network with pre-shared key

Key Concepts

  • Private DHT — Uses pre-shared key (PSK) for secure, closed peer-to-peer network
  • Gossipsub — Efficient pub/sub messaging layer for blockchain event distribution
  • Topic-based subscriptions — Subscribe to specific events (bitcoin/mainnet-block, bitcoin/mainnet-subtree, etc.)
  • Bootstrap peers — Known entry points for discovering other peers in the network
  • Static peers — Explicitly configured peers maintained for reliable connectivity
  • Peer discovery — libp2p Kademlia DHT discovers peers dynamically
  • Callbacks — Each topic has own async message handler for processing events
  • Message format — Events arrive as raw Uint8Array; caller deserializes (typically BSV transactions/blocks)

When to Use

Use network packages when you need to:

  • Monitor real-time blockchain events
  • React to new blocks as they arrive
  • Track peer connectivity and network health
  • Run an overlay service that listens for transactions
  • Build applications that need live blockchain state updates

When NOT to Use

  • For transaction broadcasting — use transaction submission endpoints
  • For historical queries — use indexers or explorer APIs
  • For UTXO lookups — use full-node RPC or @bsv/overlay lookup services
  • Without requirement for real-time updates — use batch query APIs

Architecture Overview

Network flow: your application subscribes to TeranodeListener which routes through libp2p (private DHT + gossipsub with noise encryption, Kademlia discovery, bootstrap and static peers) over TCP/Noise to Teranode peers in the P2P network

Topics Available

TopicEvent
bitcoin/mainnet-bestblockBest block message
bitcoin/mainnet-blockBlock solution found
bitcoin/mainnet-subtreeSubtree created
bitcoin/mainnet-mining_onMining enabled
bitcoin/mainnet-handshakePeer connects
bitcoin/mainnet-rejected_txTransaction rejected
bitcoin/testnet-*Testnet equivalents

Next Steps

  • @bsv/teranode-listener — Real-time blockchain event subscription
  • @bsv/overlay — Indexing service integration
  • @bsv/sdk — Transaction/block deserialization