Skip to main content

View address history (sent and received)

To inspect the transaction history of a wallet address, you can call the getHistory() method on any currency instance. This returns a list of past transactions involving the address, including received and sent amounts, transaction IDs, and block heights.

Example usage

import { initializeWallet } from 'chaingate'

async function showAddressHistory() {
// Example with a mnemonic-based wallet
const wallet = await initializeWallet.fromPhrase({
phrase: 'some bip39 phrase ...'
})

const bitcoin = wallet.currency('bitcoin')

// Get the address history (first page)
const history = await bitcoin.getHistory()

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

Pagination

You can pass an optional page number to getHistory(page). The default is page 0 (the most recent transactions).

// Fetch the second page of transaction history
const nextPage = await bitcoin.getHistory(1)

Use pagination to browse through large address histories in a performant and controlled way.

What the history includes

Each transaction in the history contains:

  • Transaction ID (txid) – The hash of the transaction.
  • Amount – The value transferred in that transaction (positive = received, negative = sent).
  • Block Height (height) – The block number where the transaction was confirmed.
  • Address Balance (addressBalance) – The total balance of the address after that transaction.

Key points

  • Per-currency: Call getHistory() on a specific currency instance (e.g., wallet.currency('bitcoin')).
  • Paginated: Supports optional paging via getHistory(pageNumber). Default is page 0.
  • Confirmed transactions: Each entry includes block height. Transactions may appear with height = null if unconfirmed.