Defined in: aa-sdk/core/src/signer/local-account.ts:22
Represents a local account signer and provides methods to sign messages and transactions, as well as static methods to create the signer from mnemonic or private key.
| Type Parameter |
|---|
|
new LocalAccountSigner<T>(inner): LocalAccountSigner<T>;Defined in: aa-sdk/core/src/signer/local-account.ts:44
A function to initialize an object with an inner parameter and derive a signerType from it.
Example
import { LocalAccountSigner } from "@aa-sdk/core";
import { privateKeyToAccount, generatePrivateKey } from "viem";
const signer = new LocalAccountSigner(
privateKeyToAccount(generatePrivateKey()),
);Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The inner parameter containing the necessary data |
Returns
LocalAccountSigner<T>
| Property | Type | Description |
|---|---|---|
| ‐ | |
| ‐ | |
( | Signs the provided message using the inner signMessage function. Example |
readonly getAddress(): Promise<`0x${string}`>;Defined in: aa-sdk/core/src/signer/local-account.ts:140
Returns the address of the inner object in a specific hexadecimal format.
Example
import { LocalAccountSigner } from "@aa-sdk/core";
import { generatePrivateKey } from "viem";
const signer =
LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey());
const address = await signer.getAddress();Returns
Promise<`0x${string}`>
A promise that resolves to the address in the format 0x{string}
Implementation of
signAuthorization(this, unsignedAuthorization): Promise<SignedAuthorization<number>>;Defined in: aa-sdk/core/src/signer/local-account.ts:119
Signs an unsigned authorization using the provided private key account.
Example
import { LocalAccountSigner } from "@aa-sdk/core";
import { generatePrivateKey } from "viem/accounts";
const signer =
LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey());
const signedAuthorization = await signer.signAuthorization({
contractAddress: "0x1234123412341234123412341234123412341234",
chainId: 1,
nonce: 3,
});Parameters
| Parameter | Type | Description |
|---|---|---|
|
| ‐ |
|
| The unsigned authorization to be signed. |
Returns
Promise<SignedAuthorization<number>>
A promise that resolves to the signed authorization.
Implementation of
SmartAccountSigner.signAuthorization
readonly signTypedData<TTypedData, TPrimaryType>(params): Promise<`0x${string}`>;Defined in: aa-sdk/core/src/signer/local-account.ts:90
Signs typed data using the given parameters.
Example
import { LocalAccountSigner } from "@aa-sdk/core";
import { generatePrivateKey } from "viem";
const signer =
LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey());
const signature = await signer.signTypedData({
domain: {},
types: {},
primaryType: "",
message: {},
});Type Parameters
| Type Parameter | Default type |
|---|---|
| ‐ |
| keyof |
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The parameters defining the typed data and primary type |
Returns
Promise<`0x${string}`>
A promise that resolves to the signed data in hexadecimal format
Implementation of
SmartAccountSigner.signTypedData
static generatePrivateKeySigner(): LocalAccountSigner<{
}>;Defined in: aa-sdk/core/src/signer/local-account.ts:200
Generates a new private key and creates a LocalAccountSigner for a PrivateKeyAccount.
Example
import { LocalAccountSigner } from "@aa-sdk/core";
const signer = LocalAccountSigner.generatePrivateKeySigner();Returns
LocalAccountSigner<{
}>
A LocalAccountSigner instance initialized with the generated private key account
static mnemonicToAccountSigner(key, opts?): LocalAccountSigner<{
}>;Defined in: aa-sdk/core/src/signer/local-account.ts:159
Creates a LocalAccountSigner using the provided mnemonic key and optional HD options.
Example
import { LocalAccountSigner } from "@aa-sdk/core";
import { generateMnemonic } from "viem";
const signer = LocalAccountSigner.mnemonicToAccountSigner(generateMnemonic());Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The mnemonic key to derive the account from. |
| Optional HD options for deriving the account. |
Returns
LocalAccountSigner<{
}>
A LocalAccountSigner object for the derived account.
static privateKeyToAccountSigner(key): LocalAccountSigner<{
}>;Defined in: aa-sdk/core/src/signer/local-account.ts:181
Creates a LocalAccountSigner instance using the provided private key.
Example
import { LocalAccountSigner } from "@aa-sdk/core";
import { generatePrivateKey } from "viem";
const signer =
LocalAccountSigner.privateKeyToAccountSigner(generatePrivateKey());Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The private key in hexadecimal format |
Returns
LocalAccountSigner<{
}>
An instance of LocalAccountSigner initialized with the provided private key