Privy enables your users to import a private key into their embedded wallet.
This allows users to bring an existing wallet into your application, enabling them to manage their assets directly within your app. For example, a user can import their MetaMask wallet private key to access and manage their assets within your app seamlessly. This method can also be used by developers to migrate users from a different embedded wallet provider to Privy.
Wallet import is only available via Privy’s React SDK, for EVM networks and Solana. Support for additional SDKs and chains is under active development.
To have your user import a private key into their embedded wallet, use the importWallet
method from the useImportWallet
hook. As a parameter to this method, pass an object containing the user’s privateKey
as a string
.
If importWallet
succeeds, the imported wallet will be added to the user’s linkedAccounts
and the wallets
array returned by the useWallets
hook, with an imported
field that is marked true
. As an example, you can find the imported wallet like so:
This method will error if the provided private key is not valid or if the user has previously imported a wallet by private key.
You can request signatures and transactions from imported wallets using Privy’s native methods, the wallet’s EIP1193 provider, or a third-party library like viem
or ethers
.
To use Privy’s native signMessage
, signTypedData
, and sendTransaction
methods with an imported wallet, simply pass the address for the imported wallet as the final optional parameter to these methods:
You can also request signatures and transactions from an imported wallet using the wallet’s EIP1193 provider or a library like viem
or ethers
.
To get the EIP1193 provider for the imported wallet, first find the corresponding ConnectedWallet
object from the useWallets
array:
Then, call the object’s getEthereumProvider
method to get an EIP1193 provider for that wallet:
You can then easily pass that EIP1193 provider to a library like viem
or ethers
to use those libraries’ interfaces to send requests to the wallet.
You can request signatures and send transactions using your imported Solana wallet just like with regular embedded Solana wallets.
Then, call the object’s signMessage
method to sign.
Privy enables your users to export the full private key for their embedded wallet, even if it was imported. This allows them to use their embedded wallet address with another wallet client, such as MetaMask in any application.
To have your user export their embedded wallet’s private key, use the exportWallet
method from the usePrivy
hook. As a parameter to this method, you must pass an object containing an address
field with the user’s imported wallet address as a string
.
As an example, you might have an export wallet button in your app like so:
To have your user export their embedded wallet’s private key, use the exportWallet
method from the usePrivy
hook. As a parameter to this method, you must pass an object containing an address
field with the user’s imported wallet address as a string
.
As an example, you might have an export wallet button in your app like so:
To have your user export their embedded wallet’s private key, use the exportWallet
method from the useSolanaWallets
hook. As a parameter to this method, you must pass an object containing an address
field with the user’s imported wallet address as a string
.
As an example, you might have an export wallet button in your app like so:
Privy enables your users to import a private key into their embedded wallet.
This allows users to bring an existing wallet into your application, enabling them to manage their assets directly within your app. For example, a user can import their MetaMask wallet private key to access and manage their assets within your app seamlessly. This method can also be used by developers to migrate users from a different embedded wallet provider to Privy.
Wallet import is only available via Privy’s React SDK, for EVM networks and Solana. Support for additional SDKs and chains is under active development.
To have your user import a private key into their embedded wallet, use the importWallet
method from the useImportWallet
hook. As a parameter to this method, pass an object containing the user’s privateKey
as a string
.
If importWallet
succeeds, the imported wallet will be added to the user’s linkedAccounts
and the wallets
array returned by the useWallets
hook, with an imported
field that is marked true
. As an example, you can find the imported wallet like so:
This method will error if the provided private key is not valid or if the user has previously imported a wallet by private key.
You can request signatures and transactions from imported wallets using Privy’s native methods, the wallet’s EIP1193 provider, or a third-party library like viem
or ethers
.
To use Privy’s native signMessage
, signTypedData
, and sendTransaction
methods with an imported wallet, simply pass the address for the imported wallet as the final optional parameter to these methods:
You can also request signatures and transactions from an imported wallet using the wallet’s EIP1193 provider or a library like viem
or ethers
.
To get the EIP1193 provider for the imported wallet, first find the corresponding ConnectedWallet
object from the useWallets
array:
Then, call the object’s getEthereumProvider
method to get an EIP1193 provider for that wallet:
You can then easily pass that EIP1193 provider to a library like viem
or ethers
to use those libraries’ interfaces to send requests to the wallet.
You can request signatures and send transactions using your imported Solana wallet just like with regular embedded Solana wallets.
Then, call the object’s signMessage
method to sign.
Privy enables your users to export the full private key for their embedded wallet, even if it was imported. This allows them to use their embedded wallet address with another wallet client, such as MetaMask in any application.
To have your user export their embedded wallet’s private key, use the exportWallet
method from the usePrivy
hook. As a parameter to this method, you must pass an object containing an address
field with the user’s imported wallet address as a string
.
As an example, you might have an export wallet button in your app like so:
To have your user export their embedded wallet’s private key, use the exportWallet
method from the usePrivy
hook. As a parameter to this method, you must pass an object containing an address
field with the user’s imported wallet address as a string
.
As an example, you might have an export wallet button in your app like so:
To have your user export their embedded wallet’s private key, use the exportWallet
method from the useSolanaWallets
hook. As a parameter to this method, you must pass an object containing an address
field with the user’s imported wallet address as a string
.
As an example, you might have an export wallet button in your app like so: