AccountSigner

Defined in: aa-sdk/ethers/src/account-signer.ts:32

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

Extends

  • Signer

Type Parameters

Type ParameterDefault type

TAccount extends SmartContractAccount

SmartContractAccount

TEntryPointVersion extends GetEntryPointFromAccount<TAccount>

GetEntryPointFromAccount<TAccount>

Constructors

Constructor

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

Defined in: aa-sdk/ethers/src/account-signer.ts:67

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

Example

1import { AccountSigner, EthersProviderAdapter } from "@aa-sdk/ethers";
2import { LocalAccountSigner } from "@aa-sdk/core";
3import { sepolia } from "@account-kit/infra";
4import { createLightAccount } from "@account-kit/smart-contracts";
5import { http } from "viem";
6
7const account = await createLightAccount({
8 transport: http("https://rpc.testnet.aepps.com"),
9 chain: sepolia,
10 signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
11});
12
13const provider = new EthersProviderAdapter();
14const signer = new AccountSigner(provider, account);

Parameters

ParameterTypeDescription

provider

EthersProviderAdapter

the ethers provider to use

account

TAccount

the smart contract account that will be used to sign user ops and send them

Returns

AccountSigner<TAccount, TEntryPointVersion>

Overrides

1Signer.constructor;

Properties

PropertyTypeDescription

_isSigner

boolean

account

TAccount

provider

EthersProviderAdapter

the ethers provider to use

sendUserOperation

(args, overrides?) => Promise<SendUserOperationResult<TEntryPointVersion>>

waitForUserOperationTransaction

(args) => Promise<`0x${string}`>

Methods

_checkProvider()

1_checkProvider(operation?): void;

Defined in: node_modules/@ethersproject/abstract-signer/lib/index.d.ts:42

Parameters

ParameterType

operation?

string

Returns

void

Inherited from

1Signer._checkProvider;

call()

1call(transaction, blockTag?): Promise<string>;

Defined in: node_modules/@ethersproject/abstract-signer/lib/index.d.ts:34

Parameters

ParameterType

transaction

Deferrable<TransactionRequest>

blockTag?

BlockTag

Returns

Promise<string>

Inherited from

1Signer.call;

checkTransaction()

1checkTransaction(transaction): Deferrable<TransactionRequest>;

Defined in: node_modules/@ethersproject/abstract-signer/lib/index.d.ts:40

Parameters

ParameterType

transaction

Deferrable<TransactionRequest>

Returns

Deferrable<TransactionRequest>

Inherited from

1Signer.checkTransaction;

connect()

1connect(provider): AccountSigner<TAccount>;

Defined in: aa-sdk/ethers/src/account-signer.ts:283

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

1import { AccountSigner, EthersProviderAdapter } from "@aa-sdk/ethers";
2import { LocalAccountSigner } from "@aa-sdk/core";
3import { sepolia } from "@account-kit/infra";
4import { createLightAccount } from "@account-kit/smart-contracts";
5import { http } from "viem";
6
7const account = await createLightAccount({
8 transport: http("https://rpc.testnet.aepps.com"),
9 chain: sepolia,
10 signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
11});
12
13const provider = new EthersProviderAdapter();
14const signer = new AccountSigner(provider, account);
15
16signer.connect(provider);

Parameters

ParameterTypeDescription

provider

EthersProviderAdapter

the provider to be set for the account signer

Returns

AccountSigner<TAccount>

the updated account signer instance

Overrides

1Signer.connect;

estimateGas()

1estimateGas(transaction): Promise<BigNumber>;

Defined in: node_modules/@ethersproject/abstract-signer/lib/index.d.ts:33

Parameters

ParameterType

transaction

Deferrable<TransactionRequest>

Returns

Promise<BigNumber>

Inherited from

1Signer.estimateGas;

getAddress()

1getAddress(): Promise<string>;

Defined in: aa-sdk/ethers/src/account-signer.ts:115

Returns the account address if the account exists.

Example

1import { AccountSigner, EthersProviderAdapter } from "@aa-sdk/ethers";
2import { LocalAccountSigner } from "@aa-sdk/core";
3import { sepolia } from "@account-kit/infra";
4import { createLightAccount } from "@account-kit/smart-contracts";
5import { http } from "viem";
6
7const account = await createLightAccount({
8 transport: http("https://rpc.testnet.aepps.com"),
9 chain: sepolia,
10 signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
11});
12
13const provider = new EthersProviderAdapter();
14const signer = new AccountSigner(provider, account);
15
16const address = await signer.getAddress();

Returns

Promise<string>

a promise that resolves to the account address

Throws

if the account is not found

Overrides

1Signer.getAddress;

getBalance()

1getBalance(blockTag?): Promise<BigNumber>;

Defined in: node_modules/@ethersproject/abstract-signer/lib/index.d.ts:31

Parameters

ParameterType

blockTag?

BlockTag

Returns

Promise<BigNumber>

Inherited from

1Signer.getBalance;

getBundlerClient()

1getBundlerClient(): BundlerClient<Transport>;

Defined in: aa-sdk/ethers/src/account-signer.ts:251

Retrieves the BundlerClient instance from the provider.

Example

1import { AccountSigner, EthersProviderAdapter } from "@aa-sdk/ethers";
2import { LocalAccountSigner } from "@aa-sdk/core";
3import { sepolia } from "@account-kit/infra";
4import { createLightAccount } from "@account-kit/smart-contracts";
5import { http } from "viem";
6
7const account = await createLightAccount({
8 transport: http("https://rpc.testnet.aepps.com"),
9 chain: sepolia,
10 signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
11});
12
13const provider = new EthersProviderAdapter();
14const signer = new AccountSigner(provider, account);
15
16const bundler = signer.getBundlerClient();

Returns

BundlerClient<Transport>

The BundlerClient instance


getChainId()

1getChainId(): Promise<number>;

Defined in: node_modules/@ethersproject/abstract-signer/lib/index.d.ts:36

Returns

Promise<number>

Inherited from

1Signer.getChainId;

getFeeData()

1getFeeData(): Promise<FeeData>;

Defined in: node_modules/@ethersproject/abstract-signer/lib/index.d.ts:38

Returns

Promise<FeeData>

Inherited from

1Signer.getFeeData;

getGasPrice()

1getGasPrice(): Promise<BigNumber>;

Defined in: node_modules/@ethersproject/abstract-signer/lib/index.d.ts:37

Returns

Promise<BigNumber>

Inherited from

1Signer.getGasPrice;

getTransactionCount()

1getTransactionCount(blockTag?): Promise<number>;

Defined in: node_modules/@ethersproject/abstract-signer/lib/index.d.ts:32

Parameters

ParameterType

blockTag?

BlockTag

Returns

Promise<number>

Inherited from

1Signer.getTransactionCount;

populateTransaction()

1populateTransaction(transaction): Promise<TransactionRequest>;

Defined in: node_modules/@ethersproject/abstract-signer/lib/index.d.ts:41

Parameters

ParameterType

transaction

Deferrable<TransactionRequest>

Returns

Promise<TransactionRequest>

Inherited from

1Signer.populateTransaction;

resolveName()

1resolveName(name): Promise<string>;

Defined in: node_modules/@ethersproject/abstract-signer/lib/index.d.ts:39

Parameters

ParameterType

name

string

Returns

Promise<string>

Inherited from

1Signer.resolveName;

sendTransaction()

1sendTransaction(transaction): Promise<TransactionResponse>;

Defined in: aa-sdk/ethers/src/account-signer.ts:194

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

Example

1import { AccountSigner, EthersProviderAdapter } from "@aa-sdk/ethers";
2import { LocalAccountSigner } from "@aa-sdk/core";
3import { sepolia } from "@account-kit/infra";
4import { createLightAccount } from "@account-kit/smart-contracts";
5import { http } from "viem";
6
7const account = await createLightAccount({
8 transport: http("https://rpc.testnet.aepps.com"),
9 chain: sepolia,
10 signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
11});
12
13const provider = new EthersProviderAdapter();
14const signer = new AccountSigner(provider, account);
15
16const tx = await signer.sendTransaction({
17 to: "0x1234567890123456789012345678901234567890",
18 value: "0x0",
19 data: "0x",
20});

Parameters

ParameterTypeDescription

transaction

Deferrable<TransactionRequest>

the transaction request to be sent

Returns

Promise<TransactionResponse>

a promise that resolves to the transaction response

Throws

if the account is not found in the provider

Overrides

1Signer.sendTransaction;

signMessage()

1signMessage(message): Promise<string>;

Defined in: aa-sdk/ethers/src/account-signer.ts:150

Signs a message using the associated account.

Example

1import { AccountSigner, EthersProviderAdapter } from "@aa-sdk/ethers";
2import { LocalAccountSigner } from "@aa-sdk/core";
3import { sepolia } from "@account-kit/infra";
4import { createLightAccount } from "@account-kit/smart-contracts";
5import { http } from "viem";
6
7const account = await createLightAccount({
8 transport: http("https://rpc.testnet.aepps.com"),
9 chain: sepolia,
10 signer: LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey()),
11});
12
13const provider = new EthersProviderAdapter();
14const signer = new AccountSigner(provider, account);
15
16const message = await signer.signMessage("hello");

Parameters

ParameterTypeDescription

message

string | Uint8Array<ArrayBufferLike>

the message to be signed

Returns

Promise<string>

a promise that resolves to the signed message

Throws

if the account is not found

Overrides

1Signer.signMessage;

signTransaction()

1signTransaction(_transaction): Promise<string>;

Defined in: aa-sdk/ethers/src/account-signer.ts:218

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

Parameters

ParameterTypeDescription

_transaction

Deferrable<TransactionRequest>

The transaction request

Returns

Promise<string>

Throws

Will always throw an error indicating transaction signing is unsupported

Overrides

1Signer.signTransaction;

isSigner()

1static isSigner(value): value is Signer;

Defined in: node_modules/@ethersproject/abstract-signer/lib/index.d.ts:43

Parameters

ParameterType

value

any

Returns

value is Signer

Inherited from

1Signer.isSigner;