Skip to main content

useFormattedBalance

function useFormattedBalance(balance): 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 KeybanAccount.getBalance().

Parameters

balance: bigint | object

The balance as a bigint.

Returns

string

The formatted balance as a string.

Example

import { useFormattedBalance } from "@keyban/sdk-react";

const formattedBalance = useFormattedBalance(BigInt(2e17));
console.log(formattedBalance); // "0.2 ETH"

Defined in

packages/sdk-react/src/FormattedBalance.tsx:20