Class MirrorNodeAccountBalanceQuery

java.lang.Object
com.hedera.hashgraph.sdk.MirrorNodeAccountBalanceQuery

public final class MirrorNodeAccountBalanceQuery extends Object
Get the HBAR balance of an account from the mirror node REST API (GET /api/v1/balances?account.id=...).

This is the replacement for AccountBalanceQuery, which relies on the consensus node CryptoService/cryptoGetBalance endpoint that the network is retiring.

The account may be identified by shard.realm.num, by an EVM address, or by a public key alias — the mirror node resolves all three. Contract IDs are also accepted; pass them through setAccountId(AccountId), as the balances endpoint supports them directly and no separate setter is needed.

Only the HBAR balance is returned. Token balances are not covered by this query.

An account the mirror node does not know fails with a PrecheckStatusException carrying Status.INVALID_ACCOUNT_ID, the same error AccountBalanceQuery reported. Note that the balances endpoint answers with an empty result rather than a 404, so this is the SDK's mapping of that empty result — not a status the mirror node itself returned.

Eventual consistency: the mirror node reflects network state with a small lag, typically a few seconds. Applications that need an immediate post-transaction balance must allow for it. The lag applies to the account's existence as well as to its balance: a freshly created account can transiently fail with Status.INVALID_ACCOUNT_ID until the mirror node has ingested it, so code that queries an account right after creating it should retry rather than treat the first failure as final.

This query is free.