useWallets
Get and manage wallets linked to the user, including the embedded wallet.
Use cases:- Show wallets linked to the user.
- Switch active wallet.
- Export embedded wallet private key.
wallets
: Linked wallets.activeWallet
: Current active wallet.setActiveWallet
: Function to change active wallet.availableWallets
: Wallets available on device.exportPrivateKey
: Export embedded wallet key.
import { useWallets } from "@openfort/react"
function SampleComponent() {
const {
wallets, // List of the wallets of the user.
availableWallets, // List of available wallets in the application.
activeWallet, // The currently active wallet in the application.
setActiveWallet, // Set the active wallet for the application.
createWallet, // Create a new wallet.
error, // The error object if an error occurred, otherwise null.
isError, // Indicates if the hook has encountered an error.
isSuccess, // Indicates if the hook has successfully completed.
isCreating,
isConnecting,
exportPrivateKey, // Export the private key of the active wallet.
} = useWallets({
throwOnError, // Whether to throw errors.
onSuccess, // Callback function to execute on success.
onError, // Callback function to execute on error.
onSettled, // Callback function to execute when the operation is settled (either success or error).
})
// ...
}