getAccountOwnedTokensFromCollectionAddress

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}")
}

Return

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

Parameters

accountAddress

The address of the account that owns the tokens.

collectionAddress

The address of the collection to query.

tokenStandard

An optional token standard to filter the results by.

sortOrder

An optional list of sorting options for the results.

page

Optional pagination arguments (limit and offset).