After minting multiple tokens using the CIS2 Contract, I want to display all the tokens from the wallet without specifying a tokenId, that means, If a wallet has 5 tokens from a contract, I want to display them all.
If you want your solution to work for any CIS2Contract deployed, then writing an indexer that listens to the following events to build a database of who owns which token of a specific cis2contract would work. Your backend would construct/maintain such a database and your front end would query the tokens own by a specific account address via an endpoint that your backend exposes.
Cis2Event::Mint , Cis2Event::Transfer, and Cis2Event::Burn events
Here are some (not advised/production ready) solutions, but might work if you just want to hack around:
The walletProxy has an API endpoints that you can query:
GET /v0/CIS2TokenBalance/{index}/{subindex}/{account address} GitHub - Concordium/concordium-wallet-proxy
e.g. If you open the URL in the browser https://wallet-proxy.testnet.concordium.com/v0/CIS2Tokens/6607/0 you get all tokens from that contract.
Querying the balance of one tokenId:
e.g. https://wallet-proxy.testnet.concordium.com/v0/CIS2TokenBalance/6607/0/4bbdAUCDK2D6cUvUeprGr4FaSaHXKuYmYVjyCa4bXSCu3NUXzA?tokenId=ee0400a9d5d07500
Querying the balance of several tokenIds:
e.g. https://wallet-proxy.testnet.concordium.com/v0/CIS2TokenBalance/6607/0/4bbdAUCDK2D6cUvUeprGr4FaSaHXKuYmYVjyCa4bXSCu3NUXzA?tokenId=ee0400a9d5d07500%2C620500a5b0107a00