Skip to main content
Trails comes with a built in high-performant indexer which you can leverage seamlessly to retrieve information about a user’s transaction history.

Wallet Transaction History

For example, querying a user’s transaction history for a specific chain using their connected wallet address:
import { useEffect, useState } from 'react'
import { useAccount } from 'wagmi'
import { getAccountTransactionHistory } from '0xtrails'

// Retrieve a user's transaction history on Polygon
export function retrieveTransactionHistory({ chainId = 137 }: { chainId?: number }) {
  const { address } = useAccount()
  const [txs, setTxs] = useState<any[]>([])

  useEffect(() => {
    if (!address) return
    getAccountTransactionHistory({ chainId, accountAddress: address })
      .then(r => setTxs(r.transactions ?? []))
  }, [address, chainId])

  return (
    <ul>
      {txs.map((tx) => (
        <li key={tx.txnHash}>
          {tx.txnHash} | chain {tx.chainId} | block #{tx.blockNumber} | {tx.timestamp}
        </li>
      ))}
    </ul>
  )
}
For more information, see:

Intent Transaction History

While getAccountTransactionHistory retrieves all transactions for a wallet address on a specific chain, getIntentTransactionHistory retrieves the transaction history for a specific intent scoped to Trails. This is useful when you want to track the lifecycle of a particular intent across multiple chains, including deposit, settlement, and withdrawal transactions.
import { useEffect, useState } from 'react'
import { getIntentTransactionHistory } from '0xtrails'

// Retrieve transaction history for a specific intent
export function retrieveIntentHistory({ intentAddress }: { intentAddress: string }) {
  const [txs, setTxs] = useState<any[]>([])

  useEffect(() => {
    if (!intentAddress) return
    getIntentTransactionHistory({ intentAddress, pageSize: 10, page: 0 })
      .then(r => setTxs(r.intents ?? []))
  }, [intentAddress])

  return (
    <ul>
      {txs.map((intent) => (
        <li key={intent.intentId}>
          Intent {intent.intentId} | {intent.originChainId}{intent.destinationChainId} | Status: {intent.status}
        </li>
      ))}
    </ul>
  )
}

Key Differences

FeaturegetAccountTransactionHistorygetIntentTransactionHistory
PurposeAll transactions for a wallet addressAll transactions for a specific intent flow
ScopeSingle chainCross-chain (origin + destination)
ParameterschainId, accountAddressintentAddress
Use CaseWallet activity dashboardTrack or query specific cross-chain operation
ReturnsIndividual transactionsIntent summaries with status
For more information, see: