signTypedData

Signs the provided typed data using the account’s private key.

Import

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

Usage

1import { WalletClientSigner } from "@aa-sdk/core";
2import { createWalletClient, custom } from "viem";
3import { mainnet } from "viem/chains";
4
5const client = createWalletClient({
6 chain: mainnet,
7 transport: custom(window.ethereum!),
8});
9
10const signer = new WalletClientSigner(client, "wallet");
11console.log(
12 await signer.signTypedData({
13 types: {
14 Message: [{ name: "content", type: "string" }],
15 },
16 primaryType: "Message",
17 message: { content: "Hello" },
18 })
19);

Parameters

typedData

TypedDataDefinition<TTypedData, TPrimaryType> The typed data to be signed

Returns

Promise<Hex> A promise that resolves to a hex string representing the signed data