Skip to main content
Mutation hook for signing EIP-712 typed data using a Viem WalletClient from useParaViemClient.
Requires @getpara/viem-v2-integration and viem as peer dependencies.
Get the viemClient parameter from useParaViemClient.

Import

import { useParaViemSignTypedData } from "@getpara/react-sdk";

Usage

import { useParaViemClient, useParaViemSignTypedData } from "@getpara/react-sdk";
import { sepolia } from "viem/chains";
import { http } from "viem";

function SignTypedData() {
  const { viemClient } = useParaViemClient({
    walletClientConfig: { chain: sepolia, transport: http() },
  });

  const { signTypedDataAsync, isPending } = useParaViemSignTypedData(viemClient);

  const handleSign = async () => {
    const sig = await signTypedDataAsync({
      domain: { name: "MyDApp", version: "1", chainId: 11155111 },
      types: { Message: [{ name: "content", type: "string" }] },
      primaryType: "Message",
      message: { content: "Hello" },
    });
    console.log("Signature:", sig);
  };

  return (
    <button onClick={handleSign} disabled={isPending}>
      {isPending ? "Signing..." : "Sign Typed Data"}
    </button>
  );
}
mutate/mutateAsync are also available alongside the named aliases. All other UseMutationResult fields (data, error, isSuccess, isError, reset, etc.) work as expected.