Skip to main content
function useExportSolanaAccount(): {
  exportSolanaAccount: (options: ExportSolanaAccountOptions) => Promise<ExportSolanaAccountResult>;
};
Hook that provides a wrapped function to export Solana account private keys with authentication checks. This hook uses useEnforceAuthenticated to ensure the user is signed in before attempting to export.

Returns

{
  exportSolanaAccount: (options: ExportSolanaAccountOptions) => Promise<ExportSolanaAccountResult>;
}

exportSolanaAccount()

exportSolanaAccount: (options: ExportSolanaAccountOptions) => Promise<ExportSolanaAccountResult>;

Parameters

ParameterType
optionsExportSolanaAccountOptions

Returns

Promise<ExportSolanaAccountResult>

Example

function ExportSolanaPrivateKey() {
  const { exportSolanaAccount } = useExportSolanaAccount();
  const { solanaAddress } = useSolanaAddress();

  const handleExport = async () => {
    if (!solanaAddress) return;

    try {
      const { privateKey } = await exportSolanaAccount({
        solanaAccount: solanaAddress
      });
      console.log("Private Key:", privateKey);
    } catch (error) {
      console.error("Failed to export private key:", error);
    }
  };

  return (
    <button onClick={handleExport}>Export Private Key</button>
  );
}
I