useAgentBalance
Poll the connected wallet's AGENT token balance so built apps can check whether the end-user can afford an operation.
import { useAgentBalance } from 'flowstack-sdk/wallet'Polls GET /billing/agent/balance for the connected wallet's AGENT token balance. For built apps that need to check whether the end-user has enough AGENT to run an operation.
Use data.available for spendable AGENT (balance minus active holds) and data.balance for total AGENT in the wallet.
Signature
const { data, isLoading, error, refetch } = useAgentBalance()Returns
| Field | Type | Description |
|---|---|---|
data | AgentBalance | null | Balance object: { balance, available, buildCredits, balanceWei, ... }. |
isLoading | boolean | Fetch in flight. |
error | string | null | Last error message. |
refetch | () => Promise<void> | Manually re-fetch the balance. |
Examples
Reading available vs total AGENT
const { data } = useAgentBalance();
// data.available — spendable AGENT (balance minus active holds)
// data.balance — total AGENT in walletSee also
useInferBalance · NeedsAgent · AgentBalanceBadge
Source: README.md#useagentbalance · Also available in llms-full.txt and registry.json.