Class MirrorNodeAccountBalance

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

public final class MirrorNodeAccountBalance extends Object
The HBAR balance of an account as reported by the mirror node REST API.

Returned by MirrorNodeAccountBalanceQuery. Token balances are not included.

  • Field Details

    • hbars

      public final Hbar hbars
      The HBAR balance of the account.
  • Constructor Details

    • MirrorNodeAccountBalance

      MirrorNodeAccountBalance(Hbar hbars)
      Constructor.
      Parameters:
      hbars - the HBAR balance of the account
  • Method Details

    • fromJson

      @Nullable static MirrorNodeAccountBalance fromJson(com.google.gson.JsonObject root)
      Create a balance from a mirror node REST JSON payload.

      The mirror node reports an account it does not know with an empty balances array — not a 404. That case is signalled by returning null; the caller decides how to report it. An account that exists but holds no HBAR is a populated entry with "balance": 0 and is parsed normally, so a genuine zero is never mistaken for a missing account.

      Parameters:
      root - the JSON object returned by GET /api/v1/balances
      Returns:
      the new balance, or null if the mirror node knows no such account
      Throws:
      IllegalStateException - if the payload is not a well-formed balances response
    • getHbars

      public Hbar getHbars()
      Extract the HBAR balance.
      Returns:
      the HBAR balance of the account
    • toString

      public String toString()
      Overrides:
      toString in class Object