Skip to main content

Overview

The Web3 Demo App is a fully interactive example that showcases the Mirador Web SDK end-to-end. It connects to browser wallets, sends real blockchain transactions, and tracks the entire lifecycle with Mirador traces. All code snippets below are extracted from the actual demo source code.

What It Demonstrates

  • Trace creation with descriptive names and structured metadata
  • Attributes for wallet, network, and transaction context
  • Tags for categorization and filtering
  • Events at each stage of the transaction lifecycle
  • Transaction hints via web3.evm.addTxHint() and web3.evm.addTx() for cross-chain correlation
  • Provider integration via Web3Plugin for automatic chain detection
  • Flush to send trace data immediately
  • Error handling and trace closure on success, failure, or rejection

SDK Integration Walkthrough

The core SDK integration lives in a single sendTransaction() function. Here’s how it works step by step.

1. Initialize the Client

The client is created once when the user provides their API key:

2. Create a Trace with Metadata

When a transaction is initiated, a new trace is created and enriched with attributes and tags:

3. Track Events Through the Transaction Lifecycle

Events are added at each significant step, capturing relevant data:
The demo uses ethers.js to send transactions and links them to the trace:
You can also capture transaction input data. When input is provided, it is emitted as a "Tx input data" event:
Or use web3.evm.addTx() to extract hash, input data, and chain from a transaction object automatically:
This enables Mirador to correlate on-chain data with your trace across any of the supported networks.

Alternative: Using MiradorProvider

Instead of manually adding transaction hints, you can wrap your wallet provider with MiradorProvider to capture all transactions automatically:
See the Provider guide for more details on using MiradorProvider with ethers.js and viem.

5. Flush and Retrieve the Trace ID

After adding the transaction hint, flush the trace to send data to Mirador and retrieve the trace ID:

6. Handle Errors and Close the Trace

Always close the trace when the operation completes, whether it succeeds or fails:

Example Trace Output

When you send a transaction through the demo, the SDK captures the following data:

Supported Networks

The demo supports 12 networks (6 mainnets and 6 testnets):

Running the Demo

1

Clone the repo and install dependencies

2

Start the development server

This builds the SDK, bundles the demo, starts a CORS proxy, and serves the app at http://localhost:8000.
3

Connect and send a transaction

Enter your Mirador API key, connect a browser wallet (MetaMask, Coinbase Wallet, etc.), switch to a testnet, and send a transaction to see the full trace lifecycle in action.

Next Steps

API Reference

Complete Client and Trace API documentation

Traces

Learn about trace lifecycle, flushing, and closing

Transaction Hints

Deep dive into cross-chain transaction correlation

Transaction Tracking

More SDK integration patterns for DeFi operations