How to get all the tokens user has on a cis2_multi derived smart contract?

I mean without passing and querying for all the tokens individually like

{
“address”: {
“Account”: [address]
}, “token_id”: token
}

lets say I don’t know how and what tokens and their ids are there in that smart contract

I’ve tried passing empty string for token_id, but doesn’t work.

or atleast how to retreive all the tokens(ids) are on the smart contract. so can query individually in the array.

I don’t see any function on the base ci2_multi example that kinda does it, except for balanceOf, which strictly takes a token_id. But was wondering how ccdscan is able to show the tokens. Does it “view” the entire smart contract, I don’t think so.

Any help is appreciated.

Thank you.

The contract itself does not have any such endpoint, since it’s expensive to keep track of such an index in general.

This information would be provided by off-chain indexers. This is how CCDScan does it, it monitors the chain and records in its database the relevant activity, and relevant tokens in the contract.

To build a list of tokens in a CIS-2 contract, you need to collect all events that are MintEvent logged by the contract. This event contains the token ID.

1 Like