get Account Collections With Owned Tokens
open suspend override fun getAccountCollectionsWithOwnedTokens(accountAddress: AccountAddressInput, tokenStandard: TokenStandard?, sortOrder: List<CollectionOwnershipV2ViewSortOrder>?, page: PaginationArgs?, minimumLedgerVersion: Long?): Result<GetAccountCollectionsWithOwnedTokensQuery.Data?, AptosIndexerError>
Queries for all collections that an account currently has tokens for.
This includes NFTs, fungible tokens, and soulbound tokens. This function first ensures the indexer is synchronized up to the specified minimumLedgerVersion before querying to guarantee up-to-date data.
Usage
val address = AccountAddress.fromString("0x...")
val resolution = aptos.getAccountCollectionsWithOwnedTokens(
accountAddress = address,
tokenStandard = TokenStandard.V2
)
when (resolution) {
is Result.Ok -> {
val collectionsData = resolution.value
println("Successfully retrieved collections data: $collectionsData")
}
is Result.Err -> println("Error retrieving collections: ${resolution.error.message}")
}Content copied to clipboard
Return
A Result which is either Result.Ok containing the query data, or Result.Err containing an AptosIndexerError.
Parameters
account Address
The address of the account to query.
token Standard
An optional token standard to filter the results by (e.g., NFT).
sort Order
An optional list of sorting options for the results.
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.