LocalAccountSigner
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 Parameters
Implements
Constructors
Constructor
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
Parameters
Returns
LocalAccountSigner
<T
>
Properties
Methods
getAddress()
Defined in: aa-sdk/core/src/signer/local-account.ts:140
Returns the address of the inner object in a specific hexadecimal format.
Example
Returns
Promise
<`0x${string}`
>
A promise that resolves to the address in the format 0x{string}
Implementation of
signAuthorization()
Defined in: aa-sdk/core/src/signer/local-account.ts:119
Signs an unsigned authorization using the provided private key account.
Example
import { class LocalAccountSigner<T extends HDAccount | PrivateKeyAccount | LocalAccount>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.
LocalAccountSigner } from "@aa-sdk/core";
import { function generatePrivateKey(): HexgeneratePrivateKey } from "viem/accounts";
const const signer: LocalAccountSigner<{
address: Address;
nonceManager?: NonceManager | undefined;
sign: (parameters: {
hash: Hash;
}) => Promise<Hex>;
... 6 more ...;
type: "local";
}>signer =
class LocalAccountSigner<T extends HDAccount | PrivateKeyAccount | LocalAccount>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.
LocalAccountSigner.LocalAccountSigner<T extends HDAccount | PrivateKeyAccount | LocalAccount>.privateKeyToAccountSigner(key: Hex): LocalAccountSigner<PrivateKeyAccount>Creates a LocalAccountSigner
instance using the provided private key.
privateKeyToAccountSigner(function generatePrivateKey(): HexgeneratePrivateKey());
const const signedAuthorization: Authorization<number, true>signedAuthorization = await const signer: LocalAccountSigner<{
address: Address;
nonceManager?: NonceManager | undefined;
sign: (parameters: {
hash: Hash;
}) => Promise<Hex>;
... 6 more ...;
type: "local";
}>signer.LocalAccountSigner<{ address: Address; nonceManager?: NonceManager | undefined; sign: (parameters: { hash: Hash; }) => Promise<Hex>; ... 6 more ...; type: "local"; }>.signAuthorization(this: LocalAccountSigner<PrivateKeyAccount>, unsignedAuthorization: Authorization<number, false>): Promise<Authorization<number, true>>Signs an unsigned authorization using the provided private key account.
signAuthorization({
contractAddress: stringcontractAddress: "0x1234123412341234123412341234123412341234",
chainId: numberChain ID.
chainId: 1,
nonce: numberNonce of the EOA to delegate to.
nonce: 3,
});
Parameters
Returns
Promise
<SignedAuthorization
<number
>>
A promise that resolves to the signed authorization.
Implementation of
SmartAccountSigner
.signAuthorization
signTypedData()
Defined in: aa-sdk/core/src/signer/local-account.ts:90
Signs typed data using the given parameters.
Example
Type Parameters
Parameters
Returns
Promise
<`0x${string}`
>
A promise that resolves to the signed data in hexadecimal format
Implementation of
SmartAccountSigner
.signTypedData
generatePrivateKeySigner()
Defined in: aa-sdk/core/src/signer/local-account.ts:200
Generates a new private key and creates a LocalAccountSigner
for a PrivateKeyAccount
.
Example
Returns
LocalAccountSigner
<{
address
: `0x${string}`
;
nonceManager?
: NonceManager
;
publicKey
: `0x${string}`
;
sign
: (parameters
) => Promise
<`0x${string}`
>;
signAuthorization
: (parameters
) => Promise
<SignAuthorizationReturnType
>;
signMessage
: (__namedParameters
) => Promise
<`0x${string}`
>;
signTransaction
: <serializer
, transaction
>(transaction
, options?
) => Promise
<IsNarrowable
<TransactionSerialized
<GetTransactionType
<transaction
>>, `0x${string}`
> extends true
? TransactionSerialized
<GetTransactionType
<transaction
>> : `0x${string}`
>;
signTypedData
: <typedData
, primaryType
>(parameters
) => Promise
<`0x${string}`
>;
source
: "privateKey"
;
type
: "local"
;
}>
A LocalAccountSigner
instance initialized with the generated private key account
mnemonicToAccountSigner()
Defined in: aa-sdk/core/src/signer/local-account.ts:159
Creates a LocalAccountSigner using the provided mnemonic key and optional HD options.
Example
Parameters
Returns
LocalAccountSigner
<{
address
: `0x${string}`
;
nonceManager?
: NonceManager
;
publicKey
: `0x${string}`
;
sign
: (parameters
) => Promise
<`0x${string}`
>;
signAuthorization?
: (parameters
) => Promise
<SignAuthorizationReturnType
>;
signMessage
: (__namedParameters
) => Promise
<`0x${string}`
>;
signTransaction
: <serializer
, transaction
>(transaction
, options?
) => Promise
<IsNarrowable
<TransactionSerialized
<GetTransactionType
<transaction
>>, `0x${string}`
> extends true
? TransactionSerialized
<GetTransactionType
<transaction
>> : `0x${string}`
>;
signTypedData
: <typedData
, primaryType
>(parameters
) => Promise
<`0x${string}`
>;
source
: "hd"
;
type
: "local"
;
getHdKey
: HDKey
;
}>
A LocalAccountSigner object for the derived account.
privateKeyToAccountSigner()
Defined in: aa-sdk/core/src/signer/local-account.ts:181
Creates a LocalAccountSigner
instance using the provided private key.
Example
Parameters
Returns
LocalAccountSigner
<{
address
: `0x${string}`
;
nonceManager?
: NonceManager
;
publicKey
: `0x${string}`
;
sign
: (parameters
) => Promise
<`0x${string}`
>;
signAuthorization
: (parameters
) => Promise
<SignAuthorizationReturnType
>;
signMessage
: (__namedParameters
) => Promise
<`0x${string}`
>;
signTransaction
: <serializer
, transaction
>(transaction
, options?
) => Promise
<IsNarrowable
<TransactionSerialized
<GetTransactionType
<transaction
>>, `0x${string}`
> extends true
? TransactionSerialized
<GetTransactionType
<transaction
>> : `0x${string}`
>;
signTypedData
: <typedData
, primaryType
>(parameters
) => Promise
<`0x${string}`
>;
source
: "privateKey"
;
type
: "local"
;
}>
An instance of LocalAccountSigner
initialized with the provided private key