How to view all assets across multiple blockchains
If your game has already minted digital assets on other blockchains, your players will still be able to see and use them in-game. This guide encapsulates our current solution for multichain architecture.
Before you start building player experiences that support assets on multiple blockchains (multi-chain), it's important to understand if your assets need to be migrated to Immutable zkEVM to avoid future rework.
We've built Immutable zkEVM as a core stack which supports the functioning of your game, as such our rule of thumb for migration is as follows:
- If you are looking to manipulate any legacy assets such as burning or crafting as part of your game mechanics, you should look at migrating assets to Immutable zkEVM first. Follow this migration guide.
- if your game only needs to verify the asset's ownership read it's metadata then you may want to simply leave legacy assets where they are, and proceed to using this guide to create your player experiences.
To allow a player to see all of their blockchain assets (either zkEVM or read-only assets from other chains), we recommend the following approach for most games.
1. Ask Players to Link their Wallets to Passport
The first step is to instruct your players to link their wallets to Passport so you know which wallets they own and where their assets are located. Ask your players to visit this page to link their wallets:
https://passport.immutable.com/external-wallets
They will see the following screen once they've logged in:
The wallet linking process is simple, just click on the "Link a MetaMask wallet" and follow the instructions. They will be presented with two options;
If they have digital assets which are on Immutable zkEVM but in MetaMask instead of Passport, they can import the assets from Metamask to Passport from here.
If they have have digital assets on another blockchain which isn't Immutable zkEVM, they can choose to link a wallet as "view only" instead.
Importing Immutable zkEVM assets to Passport requires an on-chain transaction and the assets will now be owned by the players Passport wallet instead of Metamask.
Linking a wallet as view only allows leaves the assets where they are but allows Passport to view the assets the player has on other blockchains.
If you want to import items to passport from another blockchain instead of them being view only, there is another guide about how to Migrate your assets to Immutable zkEVM.
2. Retrieve the players linked wallet addresses
The best way to get the players linked addresses is by calling getUserInfo via the API. Previously you could also use the Typescript SDK to retrieve the linked addresses, but this is being deprecated in favour of using the API.
3. Retrieve the players inventory directly from the blockchain
Now that you know all the addresses linked the players Passport account, to render the players entire inventory on screen you still need to query the different relevant endpoints for each source chain.
For Immutable zkEVM
This guide describes how to retrieve a player’s inventory using using our API or SDK.
For assets on other blockchains
There are many different options for how to find out the list of NFTs for a given wallet on other blockchains. Here are some popular options:
- Use the Alchemy Typescript SDK as documented here: getNftsForOwnerIterator - SDK (TypeScript samples provided).
- Use the Moralis API as documented here: How to get all the NFT collections owned by an address (JavaScript, TypeScript and Python samples provided).
Once you've retrieved all the digital assets the player has in their linked wallets, do any required merging and/or formatting, then pass the full data set to your front end to use as required.