still unsure how to get balance from Digital Asset #55
Answered
by
0xaptosj
dellwatson
asked this question in
Questions
-
I only get how to get the address instead of balance of my total NFT /// Generates the token's address based upon the creator's address, the collection's name and the token's name.
public fun create_token_address(creator: &address, collection: &String, name: &String): address {
object::create_object_address(creator, create_token_seed(collection, name))
}
```
I dont find function that return the number of balance here.
why not make it same like from EIP-712 ? with token index, ownerOf etc |
Beta Was this translation helpful? Give feedback.
Answered by
0xaptosj
Mar 12, 2024
Replies: 1 comment 2 replies
-
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); |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
gregnazario
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.