Skip to main content

Conditional Rendering

Conditional rendering uses jsonlogic to define client-only render alterations to the NFT based on certain on and off chain conditions.

For example, an NFT depicting an image of a moon might change to a halfmoon with a rocket landing on it if it gets 50 ๐ŸŒ“ and 30 ๐Ÿš€ emojis on it.

An NFT of an apple might rot after a certain block, turning into an image of a rotten apple, or if consumed in time by means of ๐Ÿด emoji, it becomes just an apple core.

An NFT image of a bicycle can show signs of deterioration and dilapidation if it was sold more than, say, 50 times.

A wolf image could show a pack if people have minted more than 50 wolves into this collection, or even sent wolves into the original wolf.

These interactions can have in-game effects, but can also be community-driven art. A collaborative experience where if enough people interact with an NFT in some way, its essence changes.

A logic block of an NFT might look something like this:

"logic": [
{
">": ["emotes.๐Ÿš€", 50],
"priority": [2,3,1] // change asset prio based on condition == true
},
{
">": ["emotes.โ„", 100],
"assets.0.bg": "newhash" // overrides the background image in the catalog, if such a part exists
},
{
"==": ["this.rain", "true"],
"assets.0.bg": "hash-of-rainy-background"
}
],

In the above example, you can see three scenarios playing out:

  • if the NFT gets more than 50 rocket emotes, it would show a different asset as top priority. So, a moon shows a moon landing if 50 rockets are on it.
  • if the NFT gets more than 50 snow emoji, the default background of the first asset will be overridden and show a snowy mountain instead.
  • if the NFT has its mutable attribute set to "rain" then the background becomes a rainy image

Implementations#

There are no live implementations of this specification yet.

  • Kusama (research phase)
  • EVM (research phase)
  • Pallets (research phase)