---
title: "How We Adapted a Mobile RPG for Blockchain and Enabled NFT Sales"
date: 2024-05-17
description: "NFT smart contracts and an API for one computer role-playing game, linking smart contracts with the online game. The transition from web2 to web3."
author: "MetaLamp editorial team"
intro_image: "https://metalamp.io/images/legendary_play.png"
fulltext_image: "https://metalamp.io/images/legendary_play.png"
categories:
  - name: "Magazine"
    url: "https://metalamp.io/magazine.md"
tags:
  - name: "ethereum"
    url: "https://metalamp.io/tags/ethereum.md"
  - name: "web3"
    url: "https://metalamp.io/tags/web3.md"
  - name: "mobile"
    url: "https://metalamp.io/tags/mobile.md"
  - name: "web2"
    url: "https://metalamp.io/tags/web2.md"
---

# How We Adapted a Mobile RPG for Blockchain and Enabled NFT Sales

![How We Adapted a Mobile RPG for Blockchain and Enabled NFT Sales](https://metalamp.io/images/legendary_play.png)

RPG is not just entertainment, but also a source of income.

 We developed NFT smart contracts and an API for one computer role-playing game, linking smart contracts with the online game. Spoiler: the transition from web2 to web3 worked out.

 
## An NFT game where you can earn

 Esports Heroes is the first blockchain-based esports RPG.

 At its core is character enhancement and cooperative gameplay, allowing players to progress from amateur to professional esports athletes alongside friends.

 Originally conceived under a web2 model, Esports Heroes was transformed into an innovative, free-to-play mobile game thanks to the web3 paradigm.

 ![](https://metalamp.io/images/LP_roadmap.png)

 
## NFTs and an API for interacting with smart contracts and the online game

 The creators of the online game decided to transition it from web2 to web3. We had two main tasks at hand: developing NFT smart contracts and creating an API.

 **Smart contracts:**We developed NFTs that serve as representations of in-game characters. These NFTs, built on the Polygon network, can be traded on popular marketplaces such as OpenSea, Blur, and Magic Eden.

 Together with the client's team, we decided that NFTs should have two states: Playable and Tradeable. In the Playable state, NFTs are available for use in the game, while in the Tradeable state, tokens can be resold on marketplaces.

 This approach protects the game from a common vulnerability known as Race Condition, where multiple processes attempt to simultaneously process the same data. Hackers can exploit this vulnerability to gain access to the application's currency.

 Additionally, we implemented the ability to collect royalties from NFT resales, providing an additional monetization method for the application.

 **For the API**, we developed a backend that served as a bridge between smart contracts and the game backend. This is a classic scheme used when transitioning games from web2 to web3.

 
## The technologies we used

 **Solidity.** Everything is written in Solidity. And what else?)

 **Foundry.** MetaLamp developers favor this service. Tests are written directly in Solidity, not in JS. They execute much faster than in Hardhat. Moreover, the testing toolkit in Foundry is much broader.

 **The operator-filter-registry library.**This small library was developed by the OpenSea protocol as a response to other marketplaces that did not plan to support the royalty standard.

 The library allows NFT owners to exclude certain marketplaces where these NFTs can be sold. In other words, thanks to this library, NFT owners can have more control over their business models and tokens, choose platforms for distributing NFTs, guarantee royalties, and also prohibit trading their NFTs on platforms where there are no royalties.

 As of 2024, the library is deprecated and no longer supported by OpenSea, as it didn't gain enough popularity among the community and other marketplaces. However, at the time of implementation, the solution wasn't deprecated, considered fresh and quite appealing. Now, we wouldn't use this library and would seek an alternative.

 **Beacon Pattern.** The technology is used for updating smart contracts.

 In the game, there are numerous collections with characters. Each collection is an independent smart contract with a unique address on the network. However, the smart contract code for all collections is the same.

 
## Results

 We've empowered Esports Heroes users with true ownership of their in-game assets. Up to 5% of users purchase NFTs directly on the platform.

 The project receives royalties from secondary market trading on the NFT marketplace.

 Our smart contracts underwent [audit](https://audits.webthreeconsulting.com/heroes) and received the highest rating. Not a single vulnerability was found.

 ![](https://metalamp.io/images/slack.jpeg)

 RPGs are popular among users worldwide.

 ![](https://metalamp.io/images/googleplay_eng.jpeg)

 It took us approximately a month in total. The smart contracts were completed in a week, while the backend took three weeks. Additional time was spent on communication, consultations, and support.

 On MetaLamp's side, the project involved two developers and one project manager.

 ![article-logo](https://metalamp.io/images/article/logo.svg) 
## Read more about our cases


## Custom Fields

**reading time:** 10

**Article type:** articles

**Article description:** We developed NFT smart contracts and an API for one computer role-playing game, linking smart contracts with the online game. Spoiler: the transition from web2 to web3 worked out.


**Editor's choice:** editors_choice

**Author (copy):** MetaLamp editorial team

