Skip to content

useRuneBalance

Gets the balance of a rune for an address. See getRuneBalance for more information.

Import

ts
import { useRuneBalance } from "@midl/react";

Example

tsx
function RuneBalance() {
  const { balance, isLoading, error } = useRuneBalance({
    address: "bcrt1qj0...0zq",
    runeId: "1:1",
  });

  if (isLoading) return <div>Loading...</div>;
  if (error) return <div>Error: {error.message}</div>;

  return <div>Rune Balance: {balance}</div>;
}

Parameters

NameTypeDescription
addressstring(optional) Address to fetch the rune balance for.
runeIdstringThe ID of the rune to fetch the balance for.
queryUseQueryOptions(optional) Query options for react-query.
configConfig(optional) Custom config to override the default from context.

Returns

NameTypeDescription
balanceGetRuneBalanceResponseThe balance of the specified rune.
...restobjectAdditional query state (e.g. isLoading, error, etc.).