How can I check if account own a digital asset from a collection and the amount of holding? #320
-
Discord user IDspielcrypto Describe your question in detail.I want to know how can I check if an account own some digital asset from a collection and the amount using fun checkHolderOrPayFees(account: &signer) acquires Config {
let account_address = signer::address_of(account);
let config = borrow_global<Config>(@ghostly_addr);
let fit_requirement = vector::any<NFTRequired>(&config.nfts_required, |nft_required_ref| {
let nft_required = *nft_required_ref;
let NFTRequired {
collection_addr, amount
} = nft_required;
let collection = object::address_to_object<Collection>(nft_required.collection_addr);
object::owns(collection, account_address)
});
} What error, if any, are you getting?No response What have you tried or looked at? Or how can we reproduce the error?No response Which operating system are you using?Linux (Ubuntu, Fedora, Windows WSL, etc.) Which SDK or tool are you using? (if any)N/A Describe your environment or tooling in detailaptos-move 3.4.1 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I saw this answer #55 (reply in thread), if it is true that I cannot count the token that owns an address from a collection on chain then you should change the Digital Asset as soon as possible or develop token v3 giving a mechanism to migrate V2 to V3 because then only I can do currently is to create a backend service where I can check if account own an amount of specific collection in order to let do an action, because If I do in frontend it is easily hackeable, but I don't want to do that because then I have to pay the fees each time an account call the function, at least that Aptos fundation sponsor my fees, however I'm curious why such design, what is the reason for it? Because I can get the balance from Token v1 that's why I don't understand |
Beta Was this translation helpful? Give feedback.
-
ok forget about my last comment I found a way to do onchain without being hackeable, just I get the amount in frontend and send a vector of those tokens checking if the owner owns each element from the vector onchain |
Beta Was this translation helpful? Give feedback.
ok forget about my last comment I found a way to do onchain without being hackeable, just I get the amount in frontend and send a vector of those tokens checking if the owner owns each element from the vector onchain