get Account Owned Tokens From Collection Address
abstract suspend fun getAccountOwnedTokensFromCollectionAddress(accountAddress: AccountAddressInput, collectionAddress: AccountAddressInput, tokenStandard: TokenStandard? = null, sortOrder: List<TokenOwnershipV2SortOrder>? = null, page: PaginationArgs? = null): Result<GetAccountOwnedTokensFromCollectionQuery.Data?, AptosIndexerError>
Queries for all tokens an account owns within a specific collection.
This includes all token standards (v1 and v2) such as NFTs, fungible tokens, and soulbound tokens. You can optionally filter by a specific token standard.
Usage
val accountAddr = AccountAddress.fromString("0x...")
val collectionAddr = AccountAddress.fromString("0x...")
val resolution = aptos.getAccountOwnedTokensFromCollectionAddress(
accountAddress = accountAddr,
collectionAddress = collectionAddr
)
when (resolution) {
is Result.Ok -> {
val data = resolution.value
println("Successfully retrieved owned tokens data: $data")
}
is Result.Err -> println("Error retrieving owned tokens: ${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 that owns the tokens.
collection Address
The address of the collection to query.
token Standard
An optional token standard to filter the results by.
sort Order
An optional list of sorting options for the results.
page
Optional pagination arguments (limit and offset).