Documentation Index
Fetch the complete documentation index at: https://docs.cloud.coinbase.com/llms.txt
Use this file to discover all available pages before exploring further.
function useSignEvmHash(): {
signEvmHash: (options: SignEvmHashOptions) => Promise<SignEvmHashResult>;
};
Hook that provides a wrapped function to sign EVM messages with authentication checks.
This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to sign.
Returns
{
signEvmHash: (options: SignEvmHashOptions) => Promise<SignEvmHashResult>;
}
| Name | Type |
|---|
signEvmHash() | (options: SignEvmHashOptions) => Promise<SignEvmHashResult> |
Example
function SignHash() {
const { signEvmHash } = useSignEvmHash();
const { evmAddress } = useEvmAddress();
const handleSign = async () => {
if (!evmAddress) return;
try {
const result = await signEvmHash({
evmAccount: evmAddress,
hash: "0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0"
});
console.log("Signature:", result.signature);
} catch (error) {
console.error("Failed to sign hash:", error);
}
};
return (
<button onClick={handleSign}>Sign Hash</button>
);
}