Function.useFormattedBalance
function useFormattedBalance(balance: Balance, token?: KeybanToken): string
Formats a balance in a human-readable format using the Keyban client. This is typically used to display the balance of an account, as retrieved by
Parameters
Parameter | Type | Description |
---|---|---|
balance | Balance | The raw balance to format. |
token ? | KeybanToken | The token details, if the balance is not native. |
Returns
string
- The formatted balance as a string.
Example
import { useFormattedBalance } from "@keyban/sdk-react";
const formattedBalance = useFormattedBalance({raw: BigInt(2e17), isNative: true});
console.log(formattedBalance); // "0.2 ETH"