10. The Process Flow: Extraction and Injection
Now that we’ve introduced the components, let’s walk through the process flow of using the NitroPortal, focusing on the extraction and injection of game assets.
Extraction Process:
User Selection: The user logs into the NitroPortal UI and selects the game and the specific level they are interested in. This action triggers a request from the Portal UI to the Portal API.
Login Verification: The Portal API sends a query to the Portal Game API to verify if the user is logged into the game. If there is a mapping between the user's wallet address and their in-game user ID, the response is affirmative. If the user is not linked, the Portal UI prompts for login credentials, which are then verified by the Portal Game API.
Inventory Retrieval: Once logged in, the Portal UI requests the user’s inventory items from the Portal API, which in turn queries the Portal Game API. The Portal Game API, knowing the user’s ID, returns all relevant inventory items, possibly filtered based on the game's criteria (e.g., items in a chest, equipped items, etc.).
Mapping Items to NFT Types: Along with the inventory, the Portal Game API returns the NFT Type associated with each item. This ensures that the Portal API knows exactly which game item corresponds to each potential NFT.
Smart Contract Identification: The Portal UI also queries which smart contracts are used by the game and retrieves the NFTs owned by the user’s connected wallet. The Portal Game API maps these NFTs to the corresponding game items based on their NFT Types.
Item Extraction: The user selects items from their inventory to extract, initiating the minting process. The Portal API manages the blockchain transaction, including the submission of the transaction, the handling of fees, and the event listening to confirm that the transaction was successful. Once confirmed, the Portal API sends a message to the Portal Game API, informing it of the successful extraction. The Portal Game API then removes the extracted items from the user's in-game inventory, either marking them as deleted or removing them entirely, and mints the corresponding NFT to the user’s wallet.
Injection Process:
NFT Injection: When a user decides to inject an NFT back into the game, they select the NFT from their wallet using the Portal UI. This triggers the injection process where the NFT is transferred to the game’s designated address. The Portal API manages this transaction and listens for events confirming the transfer.
Handling the NFT: The game developer can decide how the NFT is handled. In most cases, the NFT might be burned (destroyed) or escrowed (held in a specific address). If the NFT is escrowed, it remains available for future extraction.
Updating the In-Game Inventory: Once the NFT is injected, the Portal API sends a request to the Portal Game API, providing details such as the user’s wallet address, the NFT Type, and other relevant information. The Portal Game API then adds the corresponding game item back to the user’s inventory based on the NFT Type.
Last updated