function ExportPrivateKey() {
const { exportEvmAccount } = useExportEvmAccount();
const { evmAddress } = useEvmAddress();
const handleExport = async () => {
if (!evmAddress) return;
try {
const { privateKey } = await exportEvmAccount({
evmAccount: evmAddress
});
console.log("Private Key:", privateKey);
} catch (error) {
console.error("Failed to export private key:", error);
}
};
return (
<button onClick={handleExport}>Export Private Key</button>
);
}
Hook that provides a wrapped function to export EVM account private keys with authentication checks. This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to export.