The useCosmjsProtoSigner hook provides a Cosmjs Proto signer for a Para wallet.

Import

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

Usage

function CosmjsProtoSigner() {
  const { protoSigner, isLoading } = useCosmjsProtoSigner();

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

    // Create a simple sign doc for the message
    const signDoc = {
      bodyBytes: new TextEncoder().encode(
        JSON.stringify({
          messages: [],
          memo: "Test Message",
        })
      ),
      authInfoBytes: new Uint8Array(0),
      chainId: "",
      accountNumber: BigInt(0),
    };

    const result = await protoSigner.signDirect(protoSigner.address, signDoc);

    console.log("Signature:", result.signature.signature);
  };

  if (isLoading) return <div>Loading Cosmjs Proto signer...</div>;

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

Return Type

The hook returns a UseCosmjsProtoSignerReturn object with the following properties: