Hook for retrieving the balance of the selected wallet
The useWalletBalance
hook fetches the current balance of the selected wallet, supporting both Para-managed wallets and external wallets.
import { useWalletBalance } from "@getpara/react-sdk@alpha";
function WalletBalance() {
const { data: balance, isLoading, error } = useWalletBalance();
if (isLoading) return <div>Loading balance...</div>;
if (error) return <div>Error loading balance</div>;
if (!balance) {
return <div>No balance available</div>;
}
return (
<div>
<p>Balance: {balance} ETH</p>
</div>
);
}