Metaverse Gym Token-based Outfit Marketplace - Part 1

Picture1-Apr-20-2023-06-11-17-4217-PM

In this article, we will delve deeper into the concepts of the Metaverse and focus on the topic of decentralization. To demonstrate these ideas, we will enhance our Metaverse gym proof-of-concept by integrating it with the Ethereum blockchain. This integration will allow us to issue tokens that represent outfits worn by users inside the Metaverse gym.

Introduction

In our previous article, we covered on the concepts surrounding the Metaverse and related technologies. We also shared our experience in building a proof-of-concept (PoC) for a virtual gym application where users can come together to exercise and interact with each other through spatial voice chat and movement tracking. In this article, we will build on this foundation by introducing a decentralized outfit system for the virtual gym. This system will allow users to buy and sell outfits used within the gym. The ownership of these outfits will be recorded on a blockchain, providing users with the ability to trade the tokens on other platforms.

To get started, let us have a quick overview of blockchain technology.

What is a Blockchain?

Blockchain is a decentralized database of transactions that is shared and updated across a network of computers (each computer on the network holds a copy of the data). The database is immutable, so you cannot delete or update previous transactions, but only add new transactions. Transactions are grouped into blocks that have a storage capacity and once they are filled, the block is closed and linked to previous blocks to form a chain, hence the name “blockchain”. The link between the blocks is achieved by a cryptographic hash that is generated based on the current block content and the previous block hash. Thus, changing one block’s content would need changes to a chain of blocks, which could be considered impractical. 

Smart Contracts and NFTs

Smart contract is a technology that enables the creation of Non-Fungible Tokens (NFTs). NFTs are digital assets that represent the ownership of a specific item, it is used to represent the ownership of digital art (like the bored ape you’ve heard of). In summary, smart contracts are programming codes stored in the blockchain that can be called using external methods and executed under pre-defined conditions. Using smart contracts, it is possible to implement business logic such as transferring the ownership of an NFT from person A to person B when person B provides person A with the required value in cryptocurrency. 

Smart contracts also enable decentralized apps that are like conventional applications, but they use the blockchain to store data and use smart contracts to implement their logic. Once the app is deployed, it cannot be changed and is controlled by the logic implemented in it, instead of an individual or a company.

Metaverse Gym 2.0: Outfits

Decentralization and ownership are terms that often come up when talking about the Metaverse. The idea is that the Metaverse should be decentralized and not hosted by a company. In addition, people should be able to own things inside the Metaverse in the same way as we have clothes or a car in the real world. To explore this idea, we decided to incorporate an outfit system into our Metaverse Gym PoC. The idea is simple, users should be able to purchase outfits and then select those outfits to wear inside the gym. Using the ownership concept, users should be able to sell those outfits to other users, not only on our marketplace but also on other open marketplaces.

To achieve this, we created a simple web application integrated with the Ethereum blockchain that acts as our marketplace for outfits. We also integrated our Unity-based application with the Ethereum blockchain, to fetch users’ outfits information and created a simple login system using Amazon Web Services (AWS). As storing information on the blockchain has a high cost because “gas” (paid in Ether, Ethereum cryptocurrency) must be provided for each transaction that inserts or updates information, we used IPFS to store token metadata and store only the token ownership on the blockchain. IPFS stands for Interplanetary File System, and it is a distributed and immutable storage solution. For its immutable characteristic, IPFS is often used to store NFTs metadata to ensure that the token information does not change. Additionally, MetaMask was used as the cryptocurrency wallet provider for our web application, allowing us to interact with smart contracts.

We developed two smart contracts for our PoC: EncoraGymNFT and EncoraGymMarketPlace

EncoraGymNFT is our outfit tokens contract, it stores information about our outfit tokens and the corresponding ownership. The other contract, EncoraGymMarketPlace controls operations for our Marketplace. This contract has methods to list, buy, and view tokens for sale.

Picture2-Apr-20-2023-06-13-28-2831-PM

We will provide more details on smart contracts and tools/technologies used in a follow-up blog post. There, we’ll go through the challenges we face and discuss the technologies we used to overcome them.

For now, let us go for a quick Demo of our Application.

The sounds on videos were obtained from Mixkit.com.)

 

Etherscan and OpenSea

Now we are going to explore the decentralization benefits of blockchain. As you noted in the video, all the interactions with our smart contract were made from our web application. Although, as we record information publicly in the blockchain, other applications can use it as well. 

Etherscan is a block explorer and one of the most used applications for navigating the public data on the Ethereum blockchain. We can search for our contract address on Etherscan and visualize all the transactions made. 

Picture4-Apr-20-2023-06-14-49-3065-PM

Similarly, we can also find our outfit tokens on OpenSea (open marketplace for NFTs, integrated with Ethereum).

Picture5-Apr-20-2023-06-15-21-2093-PM

Note that OpenSea can also verify how many token owners there are for our collection, in this case, it is two.

The following images are from the outfit details page on OpenSea. Notice how it correctly displays token information, such as name, description, and attributes, and it can also verify the transactions that occurred.

                             Picture6-Apr-20-2023-06-16-46-7164-PM Picture7-Apr-20-2023-06-16-46-8692-PM

It even allows us to put the token for sale on OpenSea.

Picture8-Apr-20-2023-06-17-36-3964-PM

These features highlight how blockchain can be used as a shared source of information for different applications.

Enhancements

In our PoC, only the marketplace contract owner can create outfits, and you can only create outfits that correspond to outfits available in our Unity application (we use the token attributes “Body Type” and “Model Identifier” for this mapping). Although on Unity, it is possible to upload models in runtime, a feature that would highlight even further the decentralization aspects by enabling users to create their own outfits. This can be done by providing a way for the users to upload the outfit models on our marketplace application. For example, you can store this information on IPFS and retrieve it from our Unity application at runtime.

This would allow creators to create content for our application and get compensated when other users buy their outfits. It also enables brands market on our platform by allowing them to create outfits that highlight their brand.

By using a standard for the outfit metadata and model, you could even enable interoperability with other platforms, allowing users to use their outfits in multiple environments.

Conclusion

We demonstrated how the blockchain's decentralization characteristic can be a key point to enable the sense of ownership and interoperability that the Metaverse seeks. In our next article, we will outline the challenges and discuss the technologies and tools used to address them. This will give readers an insight into the development process and help them understand the thought process behind it. We will also provide more videos that explain the marketplace functionalities in more detail.

Acknowledgment

This piece was written by Guilherme Carrenho, an Innovation Expert at Encora’s Innovation Team. Thanks to Álison Ramos da Silva, Flavia de Melo Negrão, Hugo Martins Gonçalves, João Augusto Caleffi, and João Pedro São Gregorio Silva for their reviews and insights.

References

About Encora

Fast-growing tech companies partner with Encora to outsource product development and drive growth. Contact us to learn more about our software engineering capabilities

Share this post

Table of Contents