useSignTypedData
Similar to useSignMessage
, hook for signing typed data, supporting both connected accounts and clients in EIP 712 format.
Uses eth_signTypedData
to sign structured, typed data. Accepts typed, complex data structures as input. Like useSignMessage
, this hook also handles deployed (1271) and undeployed accounts (6492).
Import
import { useSignTypedData } from "@account-kit/react";
Usage
import { useSignTypedData, useSmartAccountClient } from "@account-kit/react";
const typedData = {
types: {
Message: [{ name: "content", type: "string" }],
},
primaryType: "Message",
message: { content: "Hello" },
};
const { client } = useSmartAccountClient({});
const {
signTypedData,
signTypedDataAsync,
signedTypedData,
isSigningTypedData,
error,
} = useSignTypedData({
client,
// these are optional
onSuccess: (result) => {
// do something on success
},
onError: (error) => console.error(error),
});
const result = await signTypedData({ typedData });
Parameters
args
UseSignTypedDataArgs
The arguments for the hook, including client and mutation-related arguments. ref
Returns
UseSignTypedDataResult
An object containing methods and state related to the sign typed data mutation process. ref