Hook for retrieving a Cosmjs Proto signer for a Para wallet
useCosmjsProtoSigner
hook provides a Cosmjs Proto signer for a Para wallet.
import { useCosmjsProtoSigner } from "@getpara/react-sdk";
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>
);
}
UseCosmjsProtoSignerReturn
object with the following properties: