Given the public hash of a fungible token contract, I want to get the amount of tokens owned by a wallet. I want to perform this operation off-chain so that it is free.
FA1.2 (tzip7) has getBalance() and FA2 (tzip12) has balance_of(). Can I call these without actually executing a blockchain transaction?
I have been trying to extract this information from the contract storages, which I can query from javascript using the tezostaquito package. Every contract has its own way of storing account balances though, so a general solution using this approach seems difficult.
I would like to avoid having to hard-code a query function for each token I am interested in. How is this usually done? How do wallets do it?