Skip to main content

Browse transaction history

To inspect the transaction history of a wallet address, connect to a network and call .addressHistory(). This returns paginated past transactions involving the address, including sent and received amounts, transaction IDs, and block heights. Pending transactions appear with height = null until they confirm.

Example usage​

import { importWallet, ChainGate } from 'chaingate'

const wallet = importWallet({ phrase: 'some bip39 phrase ...' })
const cg = new ChainGate()

const bitcoin = cg.connect(cg.networks.bitcoin, wallet)
const history = await bitcoin.addressHistory()

for (const tx of history) {
console.log('TXID:', tx.txid)
console.log('Amount:', tx.amount)
console.log('Block Height:', tx.height)
console.log('---')
}

Pagination​

Pass an optional page cursor to addressHistory(page):

// Fetch the next page of transaction history
const nextPage = await bitcoin.addressHistory('next-page-cursor')

Use pagination to browse through large address histories.

Different address index​

For HD wallets, check history at a specific address index:

const history = await bitcoin.addressHistory(undefined, { index: 1 })

What the history includes​

Each transaction in the history contains:

  • Transaction ID (txid) — The hash of the transaction.
  • Amount — The value transferred.
  • Block Height (height) — The block number where the transaction was confirmed.

Follow new transactions in real time​

onTransaction() calls you for every confirmed transaction of the wallet's address as soon as it lands, and onPendingTransaction() as soon as one appears in the mempool:

bitcoin.onTransaction(({ txid, received, amount }) => {
console.log(received ? 'Received' : 'Sent', amount.base(), 'BTC in', txid)
})

See Transactions.

Key points​

  • Per-network: Call addressHistory() on a specific network connector.
  • Paginated: Supports optional paging via a cursor string.
  • HD wallets: Use { index } to check history for different addresses.
  • Confirmed transactions: Entries include block height. Unconfirmed transactions may have height = null.