get Balance
open suspend override fun getBalance(address: AccountAddress, coinType: String?): Result<GetBalanceQuery.Data?, SuiError>
Fetches the balance of a specific coin type for a given address.
If the coinType
parameter is not provided, the function defaults to fetching the balance for the native SUI coin (0x2::sui::SUI
).
Return
A Result which is either:
Ok
: Containing a nullable GetBalanceQuery.Data object with the balance details. The data can benull
if the address holds no coins of the specified type.Err
: Containing a SuiError object with a list of GraphQLErrors.
Parameters
address
The AccountAddress for which to get the balance.
coin Type
An optional string representing the coin type (e.g., "0x2::sui::SUI"). Defaults to 0x2::sui::SUI
if null
.