The useViemClient hook provides a Viem account for a Para wallet.

Import

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

Usage

function ViemClient() {
  const { viemClient, isLoading } = useViemClient({
    walletClientConfig: {
      chain: sepolia,
      transport: http("https://ethereum-sepolia-rpc.publicnode.com"),
    },
  });

  const handleSign = async () => {
    if (!viemClient) {
      return;
    }

    const signatureRes = await viemClient.signMessage({
      message: "Test Message",
    });

    console.log("Signature:", signatureRes);
  };

  if (isLoading) return <div>Loading viem client...</div>;

  return (
    <div>
      <p>Address: {viemClient?.address}</p>
      <button onClick={handleSign}>Sign Message</button>
    </div>
  );
}

Return Type

The hook returns a UseViemClientReturn object with the following properties: