signTypedData
Signs the provided typed data using the account's private key.
Import
import { WalletClientSigner } from "@aa-sdk/core";
Usage
import { WalletClientSigner } from "@aa-sdk/core";
import { createWalletClient, custom } from "viem";
import { mainnet } from "viem/chains";
const client = createWalletClient({
chain: mainnet,
transport: custom(window.ethereum!),
});
const signer = new WalletClientSigner(client, "wallet");
console.log(
await signer.signTypedData({
types: {
Message: [{ name: "content", type: "string" }],
},
primaryType: "Message",
message: { content: "Hello" },
})
);
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