# AccountSigner | @aa-sdk/ethers

> Implementation of the ethers Signer interface to use with Smart Contract Accounts

> 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/account-signer.ts:32](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/account-signer.ts#L32)

Implementation of the ethers Signer interface to use with Smart Contract Accounts

## Extends

- `Signer`

## Type Parameters

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

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

      <td>
        `SmartContractAccount`
      </td>
    </tr>

    <tr>
      <td>
        `TEntryPointVersion` *extends* `GetEntryPointFromAccount`\<`TAccount`>
      </td>

      <td>
        `GetEntryPointFromAccount`\<`TAccount`>
      </td>
    </tr>

  </tbody>
</table>

## Constructors

### Constructor

```ts
new AccountSigner<TAccount, TEntryPointVersion>(provider, account): AccountSigner<TAccount, TEntryPointVersion>;
```

Defined in: [aa-sdk/ethers/src/account-signer.ts:67](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/account-signer.ts#L67)

Creates a new AccountSigner with the given ethers Provider and Smart Contract Account

#### 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";
import { http } from "viem";

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

const provider = new EthersProviderAdapter();
const signer = new AccountSigner(provider, account);
```

#### 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>
        [`EthersProviderAdapter`](EthersProviderAdapter)
      </td>

      <td>
        the ethers provider to use
      </td>
    </tr>

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

      <td>
        `TAccount`
      </td>

      <td>
        the smart contract account that will be used to sign user ops and send them
      </td>
    </tr>

  </tbody>
</table>

#### Returns

`AccountSigner`\<`TAccount`, `TEntryPointVersion`>

#### Overrides

```ts
Signer.constructor;
```

## Properties

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

  <tbody>
    <tr>
      <td>
        <a id="account" /> `account`
      </td>

      <td>
        `TAccount`
      </td>

      <td>
        ‐
      </td>
    </tr>

    <tr>
      <td>
        <a id="provider" /> `provider`
      </td>

      <td>
        [`EthersProviderAdapter`](EthersProviderAdapter)
      </td>

      <td>
        the ethers provider to use
      </td>
    </tr>

    <tr>
      <td>
        <a id="senduseroperation" /> `sendUserOperation`
      </td>

      <td>
        (`args`, `overrides?`) => `Promise`\<`SendUserOperationResult`\<`TEntryPointVersion`>>
      </td>

      <td>
        ‐
      </td>
    </tr>

    <tr>
      <td>
        <a id="waitforuseroperationtransaction" /> `waitForUserOperationTransaction`
      </td>

      <td>
        `Object`
      </td>

      <td>
        ‐
      </td>
    </tr>

  </tbody>
</table>

## Methods

### connect()

```ts
connect(provider): AccountSigner<TAccount>;
```

Defined in: [aa-sdk/ethers/src/account-signer.ts:283](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/account-signer.ts#L283)

Sets the provider for the account signer and returns the updated account signer instance.
Note: this is not necessary since the Provider is required by the constructor. This is useful
if you want to change the provider after the account signer has been created.

#### 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";
import { http } from "viem";

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

const provider = new EthersProviderAdapter();
const signer = new AccountSigner(provider, account);

signer.connect(provider);
```

#### 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>
        [`EthersProviderAdapter`](EthersProviderAdapter)
      </td>

      <td>
        the provider to be set for the account signer
      </td>
    </tr>

  </tbody>
</table>

#### Returns

`AccountSigner`\<`TAccount`>

the updated account signer instance

#### Overrides

```ts
Signer.connect;
```

---

### getAddress()

```ts
getAddress(): Promise<string>;
```

Defined in: [aa-sdk/ethers/src/account-signer.ts:115](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/account-signer.ts#L115)

Returns the account address if the account exists.

#### 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";
import { http } from "viem";

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

const provider = new EthersProviderAdapter();
const signer = new AccountSigner(provider, account);

const address = await signer.getAddress();
```

#### Returns

`Promise`\<`string`>

a promise that resolves to the account address

#### Throws

if the account is not found

#### Overrides

```ts
Signer.getAddress;
```

---

### getBundlerClient()

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

Defined in: [aa-sdk/ethers/src/account-signer.ts:251](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/account-signer.ts#L251)

Retrieves the BundlerClient instance from the provider.

#### 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";
import { http } from "viem";

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

const provider = new EthersProviderAdapter();
const signer = new AccountSigner(provider, account);

const bundler = signer.getBundlerClient();
```

#### Returns

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

The BundlerClient instance

---

### sendTransaction()

```ts
sendTransaction(transaction): Promise<TransactionResponse>;
```

Defined in: [aa-sdk/ethers/src/account-signer.ts:194](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/account-signer.ts#L194)

Sends a transaction using the account provider and returns the transaction response.

#### 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";
import { http } from "viem";

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

const provider = new EthersProviderAdapter();
const signer = new AccountSigner(provider, account);

const tx = await signer.sendTransaction({
  to: "0x1234567890123456789012345678901234567890",
  value: "0x0",
  data: "0x",
});
```

#### Parameters

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

  <tbody>
    <tr>
      <td>
        `transaction`
      </td>

      <td>
        `Deferrable`\<`TransactionRequest`>
      </td>

      <td>
        the transaction request to be sent
      </td>
    </tr>

  </tbody>
</table>

#### Returns

`Promise`\<`TransactionResponse`>

a promise that resolves to the transaction response

#### Throws

if the account is not found in the provider

#### Overrides

```ts
Signer.sendTransaction;
```

---

### signMessage()

```ts
signMessage(message): Promise<string>;
```

Defined in: [aa-sdk/ethers/src/account-signer.ts:150](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/account-signer.ts#L150)

Signs a message using the associated account.

#### 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";
import { http } from "viem";

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

const provider = new EthersProviderAdapter();
const signer = new AccountSigner(provider, account);

const message = await signer.signMessage("hello");
```

#### Parameters

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

  <tbody>
    <tr>
      <td>
        `message`
      </td>

      <td>
        `string` | `Uint8Array`\<`ArrayBufferLike`>
      </td>

      <td>
        the message to be signed
      </td>
    </tr>

  </tbody>
</table>

#### Returns

`Promise`\<`string`>

a promise that resolves to the signed message

#### Throws

if the account is not found

#### Overrides

```ts
Signer.signMessage;
```

---

### signTransaction()

```ts
signTransaction(_transaction): Promise<string>;
```

Defined in: [aa-sdk/ethers/src/account-signer.ts:218](https://github.com/alchemyplatform/aa-sdk/blob/main/aa-sdk/ethers/src/account-signer.ts#L218)

Throws an error indicating that transaction signing is not supported and advises to use `sendUserOperation` instead.

#### Parameters

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

  <tbody>
    <tr>
      <td>
        `_transaction`
      </td>

      <td>
        `Deferrable`\<`TransactionRequest`>
      </td>

      <td>
        The transaction request
      </td>
    </tr>

  </tbody>
</table>

#### Returns

`Promise`\<`string`>

#### Throws

Will always throw an error indicating transaction signing is unsupported

#### Overrides

```ts
Signer.signTransaction;
```