UTXO explorer
UtxoExplorer provides methods for UTXO-based networks: Bitcoin, Litecoin, Dogecoin, Bitcoin Cash, and Bitcoin Testnet.
import { ChainGate } from 'chaingate'
const cg = new ChainGate({ apiKey: 'your-api-key' })
const btc = cg.explore(cg.networks.bitcoin)
Available methods
| Method | Description |
|---|---|
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 |
broadcastTransaction(rawTx) | Broadcast a signed raw transaction |
estimateTransactionSize(params) | Estimate transaction size in bytes |
getNetworkLogoUrl() | Network logo URL |
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.