https://metaplay.io logo
o
According to https://docs.metaplay.io/feature-cookbooks/web3/getting-started-with-nfts.html#dependencies, NFTs are supported only on WebGL. What's the reason for that? I suppose some JS libraries are used? I wonder if there's something in the WebGL implementation that we could use for inspiration implementing them on mobile? Or any plans to add support on mobile actually?
Btw are there any plans to support Altura in addition to Immutable X?
n
Hi, as you suspect and as Nomi wrote in the general channel, the reason for WebGL is due to client-side javascript libraries. Namely a library for Immutable X for managing the wallet using the browser, which Metaplay uses to link the wallet to the player account. The practical reason for specifically supporting Immutable X is that it's what was relevant for some past cases, back when Metaplay's NFT support was initially implemented. Also in those cases, there was no pressing need to consider other platforms than WebGL/browser. I imagine it should be fundamentally possible to implement the wallet linking on mobile platforms, but will likely be a decent amount of work. As far as we understand, the wallet management systems work on web browsers, so the solution would need some way to link the user's identity from browser to the mobile app. At the moment, we don't have plans to extend the support to other NFT platforms than Immutable X. We did take the possibility into account in case a need arises, and designed the system in a way that shouldn't depend too much on Immutable X specifically, so it's not out of the question.
It could be good to hear about your plans with NFTs, how they're intended to appear interact with the game. To check if they're roughly in line with how the Metaplay server/SDK works with them.
o
@nuutti_holtta_mp would you mind having a call to discuss the design of your Immutable X integration, I could try to take inspiration from that for our Altura integration
n
Hi, at a high level there's a few parts to how the system deals with Immutable X. We imagine other platforms could be integrated in a roughly similar way. I'm afraid we don't have a great design document ready to go, but below is some information about what the thing entails. See also attached an old internal planning document from back when we were implementing this. - The client needs to prove to the server that it controls a specific Immutable X account. This happens with a cryptographic challenge. After this is done, the server associates the Immutable X and Ethereum accounts with the game player account. This association uses the server's general "social platform" system (this "social" terminology is a bit of historical jargon, originally for associating game player accounts with third-party "social platform" accounts such as Facebook login; nowadays the "social" aspect of it is less relevant). - The server queries information from Immutable X, related to NFT ownership (so it can what NFTs a game player account is supposed to own). It does a few kinds of queries (seen in ImmutableXApi.cs), such as: - Get NFT ownership updates in a given time-range (used by ImmutableXNftObserver.cs for getting NFT ownership changes in best-effort real time, without needing to explicitly trigger refreshes) - Get owner of a given NFT; get NFTs of a given owner (explicitly refreshed in some circumstances, such as when a player logs in) - Get Immutable X accounts associated with an Ethereum address (used in the auth/login validation). - The NFTs are managed per Immutable X "collection", that is, in order for the game/server to become properly aware of an NFT, the NFT collection needs to be configured in the
Web3
section in the game server's options yaml.
Some pointers: - The high-level of the client-side of the auth/login is in ImmutableXLinkSdkHelper.cs. Going more into the weeds there is ImmutableXApiBridge.cs/.jspre, and further MetaplayImxLinkSdkJsPlugin which is a helper plugin wrapping the actual Immutable X javascript SDK. - The server-side of the auth/login handling is mainly in ImmutableXLoginChallenge.cs and ImmutableXAuthenticator.cs. SessionActorBase.cs has HandleImmutableXLoginChallengeRequest() for handling the client requesting the login challenge. - This is further wired to the "social platform" system. Involved in this are Authenticator.cs, Authentication.cs (particularly the AuthenticationPlatform enum and the SocialAuthenticationClaimImmutableX class). - NftManager.cs has the server-side NFT manager actor (it's a single global actor per cluster) which is responsible for managing the NFT states. Via the NftLedgerDataFetcher.cs and ImmutableXNftObserver.cs it queries information from Immutable X. The intention of the current design is that it is not fundamentally tied to Immutable X specifically, but practically if you look at the code you'll see Immutable X mentioned explicitly in quite a few places. Integrating another platform (if it's similar enough conceptually) would hopefully work mostly similarly. For most of this there are no proper productized extension hooks though, so implementing such an integration will require modification to the SDK code.
Worth mentioning although not so much Immutable X specific: additionally there is NFT "state" management, which is more towards the game-specific side of NFTs. The server mirrors NFTs in the game's database, and allows each NFT to have state (which is visible to game code). Each NFT must be initialized for the server via the LiveOps dashboard before the server becomes aware of it. By default the server will also write out the NFT metadata to a configured S3 bucket (this can be disabled); the purpose is to allow Immutable X to read this initial metadata when the NFT is minted.
o
Thanks a lot Nuutti!