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()andweb3.evm.addTx()for cross-chain correlation - Provider integration via
Web3Pluginfor 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 singlesendTransaction() 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:4. Send Transaction and Link with web3.evm.addTxHint()
The demo uses ethers.js to send transactions and links them to the trace:
input is provided, it is emitted as a "Tx input data" event:
web3.evm.addTx() to extract hash, input data, and chain from a transaction object automatically:
Alternative: Using MiradorProvider
Instead of manually adding transaction hints, you can wrap your wallet provider withMiradorProvider to capture all transactions automatically:
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
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