Defined in: aa-sdk/ethers/src/account-signer.ts:32
Implementation of the ethers Signer interface to use with Smart Contract Accounts
Signer
| Type Parameter | Default type |
|---|---|
|
|
|
|
new 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
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
| Parameter | Type | Description |
|---|---|---|
| the ethers provider to use | |
|
| the smart contract account that will be used to sign user ops and send them |
Returns
AccountSigner<TAccount, TEntryPointVersion>
Overrides
Signer.constructor;| Property | Type | Description |
|---|---|---|
| ‐ | |
the ethers provider to use | ||
( | ‐ | |
| ‐ |
connect(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
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
| Parameter | Type | Description |
|---|---|---|
| the provider to be set for the account signer |
Returns
AccountSigner<TAccount>
the updated account signer instance
Overrides
Signer.connect;getAddress(): Promise<string>;Defined in: aa-sdk/ethers/src/account-signer.ts:115
Returns the account address if the account exists.
Example
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
Signer.getAddress;getBundlerClient(): BundlerClient<Transport>;Defined in: aa-sdk/ethers/src/account-signer.ts:251
Retrieves the BundlerClient instance from the provider.
Example
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>
The BundlerClient instance
sendTransaction(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
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
| Parameter | Type | Description |
|---|---|---|
|
| 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
Signer.sendTransaction;signMessage(message): Promise<string>;Defined in: aa-sdk/ethers/src/account-signer.ts:150
Signs a message using the associated account.
Example
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
| Parameter | Type | Description |
|---|---|---|
|
| the message to be signed |
Returns
Promise<string>
a promise that resolves to the signed message
Throws
if the account is not found
Overrides
Signer.signMessage;signTransaction(_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
| Parameter | Type | Description |
|---|---|---|
|
| The transaction request |
Returns
Promise<string>
Throws
Will always throw an error indicating transaction signing is unsupported
Overrides
Signer.signTransaction;