Skip to main content

UTXO explorer

UtxoExplorer provides methods for UTXO-based networks: Bitcoin, Litecoin, Dogecoin, Bitcoin Cash, and Bitcoin Testnet. Use it to query balances, list UTXOs, watch the mempool, or drive a custom block explorer — all behind a single ChainGate API key.

import { ChainGate } from 'chaingate'

const cg = new ChainGate()
const btc = cg.explore(cg.networks.bitcoin)

Available methods​

MethodDescription
getAddressBalance(address)Confirmed and unconfirmed balances
getAddressHistory(address, page?)Paginated transaction history
getUtxosByAddress(address, page?)List unspent transaction outputs
getTransactionDetails(txId)Full transaction details
getLatestBlock()Latest block header
getBlockByHeight(height)Fetch block by height
getBlockByHash(hash)Fetch block by hash
getFeeRate()Recommended fee rates by tier (low/normal/high/maximum)
getMempoolTransactions()Transactions in the mempool (pending transactions)
broadcastTransaction(rawTx)Broadcast a signed raw transaction
estimateTransactionSize(params)Estimate transaction size in bytes
getNetworkLogoUrl()Network logo URL

Real-time events​

The same explorer can push events to you instead of being polled — one shared connection per network, automatic reconnection, typed callbacks. See the real-time events guide.

MethodDescription
onBlock(cb) / onFullBlock(cb)New blocks, as a summary or in full
onBalance(address, cb) / onPendingBalance(address, cb)Confirmed balance changes, or the pending delta
onTransaction(address, cb) / onPendingTransaction(address, cb)Confirmed transactions, or pending ones, of an address
onMempoolTransaction(cb)Every pending transaction on the network
onError(cb)Connection and subscription errors
btc.onBalance('bc1q...', ({ confirmed }) => {
console.log('Balance changed:', confirmed.base(), confirmed.symbol)
})

Example​

const btc = cg.explore(cg.networks.bitcoin)

// Balance
const balance = await btc.getAddressBalance('bc1q...')
console.log('Confirmed:', balance.confirmed.base(), balance.confirmed.symbol)

// Fee rates
const feeRate = await btc.getFeeRate()
console.log('Normal fee:', feeRate.normal.feePerKb, 'sat/kB')

// Latest block
const block = await btc.getLatestBlock()
console.log('Latest block height:', block.height)

// Transaction history
const history = await btc.getAddressHistory('bc1q...')
for (const tx of history.transactions) {
console.log(tx.txId, tx.amount.base())
}

// UTXOs
const utxos = await btc.getUtxosByAddress('bc1q...')
for (const utxo of utxos.utxos) {
console.log(utxo.txId, utxo.vout, utxo.value.base())
}
Connector shortcut

If you have a wallet connected, you can use connector.addressUtxos() to list UTXOs for your wallet's address directly:

const connector = cg.connect(cg.networks.bitcoin, wallet)
const utxos = await connector.addressUtxos()

This is especially useful when building custom UTXO transactions — a typed replacement for low-level flows you would otherwise hand-roll with bitcoinjs-lib.