Skip to main content
function useExportEvmAccount(): {
  exportEvmAccount: (options: ExportEvmAccountOptions) => Promise<ExportEvmAccountResult>;
};
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.

Returns

{
  exportEvmAccount: (options: ExportEvmAccountOptions) => Promise<ExportEvmAccountResult>;
}

exportEvmAccount()

exportEvmAccount: (options: ExportEvmAccountOptions) => Promise<ExportEvmAccountResult>;

Parameters

ParameterType
optionsExportEvmAccountOptions

Returns

Promise<ExportEvmAccountResult>

Example

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>
  );
}