# EthersProviderAdapter | @aa-sdk/ethers

> Lightweight Adapter for SmtAccountProvider to enable Signer Creation

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

{/* This file is auto-generated by TypeDoc. Do not edit manually. */}

Defined in: [aa-sdk/ethers/src/provider-adapter.ts:20](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/provider-adapter.ts#L20)

Lightweight Adapter for SmtAccountProvider to enable Signer Creation

## Extends

- `JsonRpcProvider`

## Constructors

### Constructor

```ts
new EthersProviderAdapter(opts): EthersProviderAdapter;
```

Defined in: [aa-sdk/ethers/src/provider-adapter.ts:48](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/provider-adapter.ts#L48)

Configures and initializes the account provider based on the given options.

#### Example

```ts
import { AccountSigner, EthersProviderAdapter } from "@aa-sdk/ethers";
import { LocalAccountSigner } from "@aa-sdk/core";
import { sepolia } from "@account-kit/infra";
import { createLightAccount } from "@account-kit/smart-contracts";

const account = await createLightAccount({
  transport: http("https://rpc.testnet.aepps.com"),
  chain: sepolia,
  signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
});

const provider = new EthersProviderAdapter({
  account,
  chain: sepolia,
  rpcProvider: "https://eth-sepolia.g.alchemy.com/v2/your-api-key",
});
```

#### Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
      <th align="left">Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `opts`
      </td>

      <td>
        `EthersProviderAdapterOpts`
      </td>

      <td>
        The options for setting up the ethers provider adapter
      </td>
    </tr>

  </tbody>
</table>

#### Returns

`EthersProviderAdapter`

#### Overrides

```ts
JsonRpcProvider.constructor;
```

## Properties

<table>
  <thead>
    <tr>
      <th align="left">Property</th>
      <th align="left">Type</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        <a id="accountprovider" /> `accountProvider`
      </td>

      <td>
        `SmartAccountClient`
      </td>
    </tr>

  </tbody>
</table>

## Methods

### connectToAccount()

```ts
connectToAccount<TAccount>(account): AccountSigner<TAccount>;
```

Defined in: [aa-sdk/ethers/src/provider-adapter.ts:90](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/provider-adapter.ts#L90)

Connects the Provider to an Account and returns a Signer

#### Type Parameters

<table>
  <thead>
    <tr>
      <th align="left">Type Parameter</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `TAccount` *extends* `SmartContractAccount`
      </td>
    </tr>
  </tbody>
</table>

#### Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
      <th align="left">Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `account`
      </td>

      <td>
        `TAccount`
      </td>

      <td>
        the account to connect to
      </td>
    </tr>

  </tbody>
</table>

#### Returns

[`AccountSigner`](AccountSigner)\<`TAccount`>

an AccountSigner that can be used to sign and send user operations

---

### getBundlerClient()

```ts
getBundlerClient(): BundlerClient<Transport>;
```

Defined in: [aa-sdk/ethers/src/provider-adapter.ts:123](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/provider-adapter.ts#L123)

Creates and returns a BundlerClient using the existing account provider's transport and chain.

#### Example

```ts
import { AccountSigner, EthersProviderAdapter } from "@aa-sdk/ethers";
import { LocalAccountSigner } from "@aa-sdk/core";
import { sepolia } from "@account-kit/infra";
import { createLightAccount } from "@account-kit/smart-contracts";

const account = await createLightAccount({
  transport: http("https://rpc.testnet.aepps.com"),
  chain: sepolia,
  signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
});

const provider = new EthersProviderAdapter({
  account,
  chain: sepolia,
  rpcProvider: "https://eth-sepolia.g.alchemy.com/v2/your-api-key",
});

const bundlerClient = provider.getBundlerClient();
```

#### Returns

`BundlerClient`\<[`Transport`](https://viem.sh)>

A bundler client configured with the existing account provider.

---

### send()

```ts
send(method, params): Promise<any>;
```

Defined in: [aa-sdk/ethers/src/provider-adapter.ts:79](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/provider-adapter.ts#L79)

Rewrites the send method to use the account provider's EIP-1193
compliant request method

#### Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
      <th align="left">Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `method`
      </td>

      <td>
        `any`
      </td>

      <td>
        the RPC method to call
      </td>
    </tr>

    <tr>
      <td>
        `params`
      </td>

      <td>
        `any`\[]
      </td>

      <td>
        the params required by the RPC method
      </td>
    </tr>

  </tbody>
</table>

#### Returns

`Promise`\<`any`>

the result of the RPC call

#### Overrides

```ts
JsonRpcProvider.send;
```

---

### fromEthersProvider()

```ts
static fromEthersProvider(provider, chain): EthersProviderAdapter;
```

Defined in: [aa-sdk/ethers/src/provider-adapter.ts:139](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/provider-adapter.ts#L139)

Creates an instance of EthersProviderAdapter from an ethers.js JsonRpcProvider.

#### Parameters

<table>
  <thead>
    <tr>
      <th align="left">Parameter</th>
      <th align="left">Type</th>
      <th align="left">Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        `provider`
      </td>

      <td>
        `JsonRpcProvider`
      </td>

      <td>
        the ethers JSON RPC provider to convert
      </td>
    </tr>

    <tr>
      <td>
        `chain`
      </td>

      <td>
        [`Chain`](https://viem.sh)
      </td>

      <td>
        the chain to connect to
      </td>
    </tr>

  </tbody>
</table>

#### Returns

`EthersProviderAdapter`

an instance of EthersProviderAdapter