React Hooks
usePusdBalance

usePusdBalance

The usePusdBalance hook retrieves the connected user's wallet balance of PUSD (PayStreamer USD) tokens. This is used to warn or prevent users from depositing more than their wallet contains.

Usage

import { usePusdBalance } from "@paystreamer/sdk/react";
 
function WalletBalanceDisplay() {
  const { data: balance, isLoading, error } = usePusdBalance();
 
  if (isLoading) return <span>Loading...</span>;
  if (error) return <span>Error</span>;
 
  const usdBalance = balance ? Number(balance) / 1e9 : 0;
 
  return (
    <div>
      <span>Wallet Balance: {usdBalance.toFixed(2)} PUSD</span>
    </div>
  );
}

Returns

An object matching the React Query result structure:

PropertyTypeDescription
databigint | undefinedThe current PUSD balance in the user's wallet (in MIST units).
isLoadingbooleanTrue if the balance is currently fetching.
errorError | nullError object if the query fails.