Guide: Dynamic NFTs & Web3 Social Progression Games

Guide: Dynamic NFTs & Web3 Social Progression Games

2023-11-28

Introduction

In the world of gaming, progression systems have long been a cornerstone of player engagement, offering a sense of achievement and growth as players interact within a game's ecosystem. Progression systems in gaming are mechanisms that allow players to advance their characters, skills, or storylines through achievements and accumulated experience. Traditionally, these progression systems have been confined to the boundaries of the game itself. However, with the rise of Web3 and the integration of social platforms into blockchain technology, a new paradigm is emerging.

Web3 social data can now be harnessed to build NFTs that progress and evolve based on a player's interactions and activities on social platforms. This innovative approach to game design not only enriches the gaming experience but also blurs the lines between the virtual gaming world and social engagement, rewarding players for their participation in the Web3 social sphere.

Web3 Social Progression Games

Phat Contract is also being used to create fully on-chain games. For instance, developer Shubham Patel has used Phat Contract to create a game called "Lens-Phite". This game leverages the power of Phat Contract to perform complex off-chain computations in real-time, providing a seamless gaming experience.

For web3 builders, this use case shows how you can create immersive gaming experiences entirely on-chain. This not only provides transparency and security, but also opens up new possibilities for player interaction and engagement.

For example, the code snippet below is part of the Phat Contract 2.0 script fetchLensApiStats(lensApi: string, profileId: string) where the Lens Phite game is able to make a batchHttpRequest to get information from Lens API and Railway API to retrieve the 3 available attacks and the nature properties of the Lens Profile fighter NFTs. These dynamic properties allow for the Lens Phite game to have strong attacks based on how much the user interacts on Lens Protocol creating a progression mechanism that lives in and outside of the gaming application.

let headers = {
  "Content-Type": "application/json",
  "User-Agent": "phat-contract",
};
let query = JSON.stringify({
  query: `query Profile {
          profile(request: { profileId: \"${profileId}\" }) {
              stats {
                  totalFollowers
                  totalFollowing
                  totalPosts
                  totalComments
                  totalMirrors
                  totalPublications
                  totalCollects
              }
          }
      }`,
  });
let body = stringToHex(query);
// In Phat Function runtime, we not support async/await, you need use `pink.batchHttpRequest` to
// send http request. The function will return an array of response.
//
let [response1,response2] = pink.batchHttpRequest(
  [
    {
      url: lensApi,
      method: "POST",
      headers,
      body,
      returnTextBody: true,
    },
    {
      url:`https://node-api-production-bfa7.up.railway.app/api/products?lens_id=${profileId}`,
      method:"GET",
      headers,
      returnTextBody:true
    }
  ],
  10000
);

if (response1.statusCode !== 200) {
  console.log(
    `Fail to read Lens api with status code: ${response1.statusCode}, error: ${
      response1.error || response1.body
    }}`
  );
  throw Error.FailedToFetchData;
}
let respBody = response1.body;
let resBody2 = response2.body;
let aa = [];
aa.push(respBody,resBody2);

Another example comes from developer Koisose, who created a game called "Lens Contract Fighter". This game showcases how Phat Contract can be used to create immersive on-chain games with dynamic features.

This use case can inspire web3 builders to leverage the power of smart contracts to create applications that are not only fun but also leverage the unique advantages of blockchain technology.

Closing

As developers continue to explore the possibilities of Phat Contract and other blockchain technologies, we can anticipate a future where games are not just isolated experiences but interconnected ecosystems that reward players for their contributions across various platforms. This could redefine the concept of value in gaming, making every social interaction a potential catalyst for in-game progression. The potential for innovation is vast, and the implications for player engagement and retention are profound. We stand on the cusp of a new era in gaming, where every action in the Web3 space can have a tangible impact on our virtual experiences.

About Phala

Phala Network is a decentralized cloud that offers secure and scalable computing for Web3.

With Phat Contracts, an innovative programming model enabling trustless off-chain computation, developers can create new Web3 use cases.

Get the latest Phala Content Straight To Your Inbox.