Hook for retrieving the currently selected wallet
The useWallet
hook provides access to the currently selected wallet’s information.
import { useWallet } from "@getpara/react-sdk@alpha";
function WalletInfo() {
const { data: wallet, isLoading, error } = useWallet();
const para = useClient();
if (isLoading) return <div>Loading wallet...</div>;
if (error) return <div>Error loading wallet</div>;
if (!wallet) {
return <div>No wallet selected</div>;
}
return (
<div>
<p>Wallet ID: {wallet.id}</p>
<p>Type: {wallet.type}</p>
<p>Address: {para.getDisplayAddress(wallet.id, {
truncate: true,
addressType: wallet.type
})}</p>
<p>Is External: {wallet.isExternal ? "Yes" : "No"}</p>
</div>
);
}