Leveling Up with Dynamic NFTs
In Pirate Nation, all of your NFTs and their metadata are fully dynamic, upgradable, and generated on-chain. This means that as you play the game with your pirates, they earn XP and level-up. Unlike other games, however, we have no centralized server that’s controlling this ability. It’s ALL happening on-chain! In order to pull this off, we built a new contract framework for dynamic token metadata that enables NFTs to evolve as the game is played.
TL;DR: All of our tokens generate their metadata on-chain and utilize a Traits system that enables gameplay to modify the traits for a NFT. This means your NFTs evolve and improve, permanently, as you play the game!.
Dynamic vs Static NFTs
NFTs all have a set of metadata that describes assets including name, image, description, traits, and so on. All NFTs, based on the ERC721 standard, have a function called tokenURI() that sites like OpenSea use to load the metadata for a given NFT.
In most cases, this tokenURI points to some file somewhere that has the NFT’s metadata in a static form looking something like the below:
{“name”: “Ape #123”,“description”: “An ape”“image”: “https://myapes.com/apes/123.png”}
This file is uploaded once, usually around the time of mint, and then usually never touched again. This is fine for PFP and other static NFTs, but for games where your characters can evolve and level-up, it’s too restrictive.
Centralized Metadata (Off-chain)
Many projects work around this issue by centralizing their metadata by having their tokenURI point to their API to return the metadata dynamically (e.g.: http://myapes.com/ape/123.json). Even major projects like CryptoKitties centralize their metadata.
The problem with centralized metadata is that the server that is hosting the metadata can be shut down for various reasons. This means that the metadata (and potentially image data) for any of the NFTs for the game are no longer available.
Dynamic Metadata (On-chain)
The way that the metadata works in Pirate Nation is a paradigm shift over static metadata and revolutionizes what can be done with NFTs. We generate the tokenURI data on-chain in the code of the smart contract.
As the player takes action on-chain within the game contract, the game updates the traits for the NFT. For example, the player can complete a quest which grants XP to the NFT used in the quest. This is updated within a TraitsContract. When the game website (or a 3rd party like OpenSea), tries to retrieve information on an NFT, the NFT contract retrieves the traits for the NFT from the TraitsContract and then generates token metadata dynamically.
Because this metadata is all stored and generated on-chain, it’s fully decentralized! It also means that the game will always exist as long as the blockchain it has been deployed on exists.
We see gameplay as a form of expression and, with dynamic NFTs, the mark you are creating will live forever on-chain.
While we are still identifying the unique ways we can use this technology to build new types of decentralized gameplay, at Proof of Play/Pirate Nation we believe that your NFTs are not just static one-time representations or simply access cards to a game, we believe they are living/evolving entities that can grow, change, split, and ultimately, follow you throughout your journey as a player. We’re excited to keep experimenting with how far we can take this idea
If you have any ideas on how we could use this to make more fun game features, please let us know in our Discord.