Skip to main content

Overview

Transaction hints allow you to correlate traces with blockchain transactions. When you add a transaction hash to a trace, Mirador follows the transaction wherever it goes — across bridges, through different protocols, and onto other chains — providing full end-to-end visibility from your application code to on-chain settlement.

Adding Transaction Hints

trace.addTxHint('0x123abc...', 'ethereum');

With Details

Add optional context about the transaction:
trace.addTxHint('0x123abc...', 'ethereum', 'Main swap transaction');
trace.addTxHint('0x456def...', 'polygon', 'Bridge to Polygon');

Supported Chains

ChainValue
Ethereum'ethereum'
Polygon'polygon'
Arbitrum'arbitrum'
Base'base'
Optimism'optimism'
BSC'bsc'
import type { ChainName } from '@miradorlabs/web-sdk';

const chain: ChainName = 'ethereum';
trace.addTxHint(txHash, chain);

Multiple Transaction Hints

A single trace can include multiple transaction hints. This is useful for complex operations that span multiple transactions. Mirador automatically follows each transaction across chains, bridges, and protocols, so you get full visibility into the entire flow:
const trace = client.trace({ name: 'CrossChainSwap' })
  .addEvent('swap_initiated');

// First transaction on Ethereum — Mirador follows it through the DEX
trace.addTxHint(ethTxHash, 'ethereum', 'Swap ETH to USDC');

// Bridge transaction — Mirador tracks it as it crosses to Polygon
trace.addTxHint(bridgeTxHash, 'ethereum', 'Bridge to Polygon');

// Final transaction on Polygon — full end-to-end trace across chains
trace.addTxHint(polygonTxHash, 'polygon', 'Receive on Polygon');

Complete Example

import { Client } from '@miradorlabs/web-sdk';

const client = new Client('your-api-key');

async function executeSwap(params: SwapParams) {
  const trace = client.trace({ name: 'TokenSwap' })
    .addAttributes({
      inputToken: params.inputToken,
      outputToken: params.outputToken,
      inputAmount: params.amount,
      userAddress: params.userAddress
    })
    .addTags(['swap', 'dex', params.chain])
    .addEvent('swap_initiated');

  try {
    // User signs transaction
    trace.addEvent('user_signing');
    const tx = await wallet.sendTransaction(swapTx);

    trace.addEvent('transaction_sent', { txHash: tx.hash });

    // Add transaction hint for correlation
    trace.addTxHint(tx.hash, params.chain, 'Swap transaction');

    // Wait for confirmation
    const receipt = await tx.wait();

    trace.addEvent('transaction_confirmed', {
      blockNumber: receipt.blockNumber,
      gasUsed: receipt.gasUsed.toString()
    });

  } catch (error) {
    trace.addEvent('swap_failed', { error: error.message });
  }
}

Method Signature

addTxHint(
  txHash: string,
  chain: ChainName,
  details?: string
): Trace
ParameterTypeRequiredDescription
txHashstringYesThe transaction hash
chainChainNameYesThe blockchain network
detailsstringNoAdditional context

Best Practices

Add Hints as Soon as You Have the Hash

Don’t wait for confirmation to add the hint:
const tx = await wallet.sendTransaction(txData);

// Add hint immediately after sending
trace.addTxHint(tx.hash, 'ethereum');

// Then wait for confirmation
await tx.wait();

Include Descriptive Details

When dealing with multiple transactions, details help identify each one:
trace.addTxHint(approveTx, 'ethereum', 'Token approval');
trace.addTxHint(swapTx, 'ethereum', 'Swap execution');

Match Chain to Transaction

Always use the correct chain for the transaction:
// Correct
trace.addTxHint(polygonTxHash, 'polygon');

// Incorrect - wrong chain
trace.addTxHint(polygonTxHash, 'ethereum');

Next Steps