signMessageWith6492
This method supports signing messages for deployed smart accounts, as well as undeployed accounts (counterfactual addresses) using ERC-6492.
Usage
ts
import { smartAccountClient } from "./smartAccountClient";
// sign message (works for undeployed and deployed accounts)
const signedMessageWith6492 = smartAccountClient.signMessageWith6492({
message: "test",
});
ts
import { createMultiOwnerModularAccount } from "@alchemy/aa-accounts";
import {
LocalAccountSigner,
SmartAccountSigner,
createSmartAccountClient,
polygonMumbai,
} from "@alchemy/aa-core";
import { http } from "viem";
const chain = polygonMumbai;
const signer: SmartAccountSigner = LocalAccountSigner.mnemonicToAccountSigner(
"YOUR_OWNER_MNEMONIC"
);
const rpcTransport = http("https://polygon-mumbai.g.alchemy.com/v2/demo");
export const smartAccountClient = createSmartAccountClient({
transport: rpcTransport,
chain,
account: await createMultiOwnerModularAccount({
transport: rpcTransport,
chain,
signer,
}),
});
Returns
Promise<Hash>
A Promise
containing the signature of the message, additionally wrapped in EIP-6492 format if the account is undeployed
Parameters
message: SignableMessage
The message to sign, of this viem type
account?: SmartContractAccount
If your client was not instantiated with an account, then you will have to pass the account in to this call.