get Account Tokens Count
abstract suspend fun getAccountTokensCount(accountAddress: AccountAddressInput, page: PaginationArgs? = null, minimumLedgerVersion: Long? = null): Result<Long, AptosIndexerError>
Queries the total count of tokens owned by a specific account.
This function first ensures the indexer is synchronized up to the specified minimumLedgerVersion before querying to guarantee the count is up-to-date.
Usage
val address = AccountAddress.fromString("0x...")
val resolution = aptos.getAccountTokensCount(address)
when (resolution) {
is Result.Ok -> {
val count = resolution.value
println("Account owns $count tokens.")
}
is Result.Err -> println("Error retrieving tokens count: ${resolution.error.message}")
}Content copied to clipboard
Return
A Result which is either Result.Ok containing the total token count as a Long, or Result.Err containing an AptosIndexerError.
Parameters
account Address
The address of the account to query.
page
Optional pagination arguments (limit and offset).
minimum Ledger Version
An optional ledger version. The function will wait for the indexer to be at or beyond this version before querying.