signMessage
signMessage
is a method on AccountSigner
that signs messages with the AccountSigner
's connected EOA signer address.
Usage
ts
import { accountSigner } from "./ethers-signer";
// sign message with the account signer's connected EOA signer address
const signedMessage = await accountSigner.signMessage("test");
ts
import { createLightAccount } from "@alchemy/aa-accounts";
import {
LocalAccountSigner,
SmartAccountSigner,
polygonMumbai,
} from "@alchemy/aa-core";
import { http } from "viem";
import { provider } from "./ethers-provider.js";
const eoaSigner: SmartAccountSigner =
LocalAccountSigner.mnemonicToAccountSigner(process.env.YOUR_OWNER_MNEMONIC!);
const chain = polygonMumbai;
// 2. Connect the provider to the smart account signer
export const accountSigner = provider.connectToAccount(
await createLightAccount({
chain,
transport: http("RPC_URL"),
signer: eoaSigner,
})
);
Returns
Promise<string>
A Promise
containing the hex signature of the message
Parameters
msg: string | Uint8Array
The message to sign