getWalletPrivateKey method from the useGetWalletPrivateKey hook.
This method returns the private key encrypted using HPKE (Hybrid Public Key Encryption). Your app provides its own P-256 public key and receives the encrypted private key which must be decrypted client-side.
Programmatic export is only supported for TEE-based wallets. On-device wallet environments do not
support this feature. Learn more.
Usage
getWalletPrivateKey method accepts an object with the following parameters:
The address of the embedded wallet to export.
Base64-encoded SPKI P-256 public key. The private key will be encrypted to this public key using
HPKE.
Returns
Returns a Promise for anEncryptedWalletKey object:
Base64-encoded HPKE ciphertext containing the encrypted private key.
Base64-encoded HPKE encapsulated key needed for decryption.
The chain type of the exported wallet.
Example
- Ethereum: Hex-encoded key (e.g.,
0x...or without prefix) - Solana: Base58-encoded key
Errors
The method throws aPrivyClientError in the following cases:

