> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirador.org/llms.txt
> Use this file to discover all available pages before exploring further.

# MiradorProvider

> EIP-1193 provider wrapper for automatic transaction capture

**Web Client SDK:**

```typescript theme={null}
import { MiradorProvider } from '@miradorlabs/web-sdk';
```

**Node.js SDK:**

```typescript theme={null}
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

```typescript theme={null}
new MiradorProvider(
  underlying: EIP1193Provider,
  client: Client,
  options?: MiradorProviderOptions
)
```

### Parameters

| Parameter    | Type                     | Required | Description                    |
| ------------ | ------------------------ | -------- | ------------------------------ |
| `underlying` | `EIP1193Provider`        | Yes      | The underlying wallet provider |
| `client`     | `Client`                 | Yes      | Mirador client instance        |
| `options`    | `MiradorProviderOptions` | No       | Configuration options          |

### MiradorProviderOptions

| Option         | Type           | Description                                                 |
| -------------- | -------------- | ----------------------------------------------------------- |
| `trace`        | `Trace`        | Bind to an existing trace (otherwise a new trace per tx)    |
| `traceOptions` | `TraceOptions` | Options for auto-created traces (ignored if `trace` is set) |

### Examples

**Basic usage:**

```typescript theme={null}
const client = new Client('api-key');
const provider = new MiradorProvider(window.ethereum, client);
```

**With trace options:**

```typescript theme={null}
const provider = new MiradorProvider(window.ethereum, client, {
  traceOptions: {
    name: 'WalletTransactions',
    maxRetries: 5
  }
});
```

**Bound to a trace:**

```typescript theme={null}
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.

```typescript theme={null}
async request(args: { method: string; params?: unknown[] }): Promise<unknown>
```

#### Intercepted Methods

| Method                   | Behavior                                            |
| ------------------------ | --------------------------------------------------- |
| `eth_sendTransaction`    | Captures tx hash, chain, input data, and errors     |
| `eth_sendRawTransaction` | Captures tx hash and errors                         |
| All other methods        | Passed through to the underlying provider unchanged |

#### Parameters

| Parameter     | Type        | Description       |
| ------------- | ----------- | ----------------- |
| `args.method` | `string`    | RPC method name   |
| `args.params` | `unknown[]` | Method parameters |

#### Returns

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

#### Examples

```typescript theme={null}
// 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

<CardGroup cols={2}>
  <Card title="EIP-1193 Provider Guide" icon="wallet" href="/concepts/provider">
    Detailed guide with library integration examples
  </Card>

  <Card title="Types" icon="code" href="/api-reference/types">
    EIP1193Provider, MiradorProviderOptions
  </Card>
</CardGroup>
