Skip to content

still unsure how to get balance from Digital Asset #55

Answered by 0xaptosj
dellwatson asked this question in Questions
Discussion options

You must be logged in to vote

The only way to get your NFT balance in a collection is to query indexer, because Aptos's digital asset standard (and fungible asset) is based on object, i.e. it's more like UTXO model where we try to store data under each user instead of like account model where we store all users' data in one big table.

  import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
  const config = new AptosConfig({
    network: Network.TESTNET,
  });
  export const aptos = new Aptos(config);

  const result = await aptos.getAccountOwnedTokensFromCollectionAddress({
    accountAddress: ownerAddr,
    collectionAddress: COLLECTION_ID,
  });

  console.log("my nfts in the collection", result);

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@dellwatson
Comment options

@0xaptosj
Comment options

Answer selected by gregnazario
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nft Questions related to NFTs and digital asset / token standards
2 participants