Skip to main content
Web Client SDK:
import { MiradorProvider } from '@miradorlabs/web-sdk';
Node.js SDK:
import { MiradorProvider } from '@miradorlabs/nodejs-sdk';

Overview

MiradorProvider wraps any EIP-1193 compatible provider and automatically captures transaction data into Mirador traces. It intercepts eth_sendTransaction and eth_sendRawTransaction calls, recording tx hints and errors, while passing all other RPC methods through unchanged.

Constructor

new MiradorProvider(
  underlying: EIP1193Provider,
  client: Client,
  options?: MiradorProviderOptions
)

Parameters

ParameterTypeRequiredDescription
underlyingEIP1193ProviderYesThe underlying wallet provider
clientClientYesMirador client instance
optionsMiradorProviderOptionsNoConfiguration options

MiradorProviderOptions

OptionTypeDescription
traceTraceBind to an existing trace (otherwise a new trace per tx)
traceOptionsTraceOptionsOptions for auto-created traces (ignored if trace is set)

Examples

Basic usage:
const client = new Client('api-key');
const provider = new MiradorProvider(window.ethereum, client);
With trace options:
const provider = new MiradorProvider(window.ethereum, client, {
  traceOptions: {
    name: 'WalletTransactions',
    maxRetries: 5
  }
});
Bound to a trace:
const trace = client.trace({ name: 'CheckoutFlow' });
const provider = new MiradorProvider(window.ethereum, client, { trace });

Methods

request()

Send an RPC request through the provider. Implements the EIP-1193 request interface.
async request(args: { method: string; params?: unknown[] }): Promise<unknown>

Intercepted Methods

MethodBehavior
eth_sendTransactionCaptures tx hash, chain, input data, and errors
eth_sendRawTransactionCaptures tx hash and errors
All other methodsPassed through to the underlying provider unchanged

Parameters

ParameterTypeDescription
args.methodstringRPC method name
args.paramsunknown[]Method parameters

Returns

Promise<unknown> — the RPC response from the underlying provider

Examples

// Transaction — intercepted and captured
const txHash = await provider.request({
  method: 'eth_sendTransaction',
  params: [{
    from: '0xabc...',
    to: '0xdef...',
    data: '0xa9059cbb...',
    value: '0x0'
  }]
});

// eth_call — passed through unchanged
const result = await provider.request({
  method: 'eth_call',
  params: [{ to: '0xdef...', data: '0x...' }, 'latest']
});

Captured Data

On Successful Transaction

When eth_sendTransaction succeeds, the following is captured in the trace:
  • TxHint: transaction hash + chain + input data (calldata)
  • Event tx:sent: { txHash, method: 'eth_sendTransaction' }

On Failed Transaction

When a transaction fails (user rejection, revert, etc.), the following is captured:
  • Event tx:error: { message, code, data, method }
The original error is always re-thrown.

Next Steps

EIP-1193 Provider Guide

Detailed guide with library integration examples

Types

EIP1193Provider, MiradorProviderOptions