getAccountCoinsData

open suspend override fun getAccountCoinsData(accountAddress: AccountAddressInput, minimumLedgerVersion: Long?, sortOrder: List<FungibleAssetSortOrder>?, page: PaginationArgs?): Result<GetAccountCoinsDataQuery.Data?, AptosIndexerError>

Queries an account's fungible asset (coin) data from the indexer.

This function first ensures the indexer is synchronized up to the specified minimumLedgerVersion before querying. This guarantees that the returned data is recent and accurate relative to a known transaction.

Usage

val address = AccountAddress.fromString("0x...")
val resolution = aptos.getAccountCoinsData(address)

when (resolution) {
is Result.Ok -> {
val coins = resolution.value?.current_fungible_asset_balances ?: emptyList()
println("Account holds ${coins.size} different types of coins.")
}
is Result.Err -> println("Error retrieving coins data: ${resolution.error.message}")
}

Return

A Result which is either Result.Ok containing the query GetAccountCoinsDataQuery.Data, or Result.Err containing an AptosIndexerError.

Parameters

accountAddress

The address of the account to query.

minimumLedgerVersion

An optional ledger version. The function will wait for the indexer to be at or beyond this version before querying.

sortOrder

An optional list of sorting options for the results.

page

Optional pagination arguments (limit and offset).