signAuthorization

Signs an unsigned authorization using the provided private key account.

Import

1import { LocalAccountSigner } from "@aa-sdk/core";

Usage

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(): Hex
generatePrivateKey
} 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(): Hex
generatePrivateKey
());
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: string
contractAddress
: "0x1234123412341234123412341234123412341234",
chainId: number

Chain ID.

chainId
: 1,
nonce: number

Nonce of the EOA to delegate to.

nonce
: 3,
});

Parameters

unsignedAuthorization

AuthorizationRequest<number>

  • The unsigned authorization to be signed.

Returns

Promise<SignedAuthorization<number>> A promise that resolves to the signed authorization.