Dynamic NFT Standard on Flow

Hi! This is my first blog post ever, so this should be interesting. I am here to introduce a Dynamic NFT Standard on the Flow Blockchain.

What is a Dynamic NFT?

A Dynamic NFT can have its metadata updated after it is minted. Metadata simply refers to the data associated with the NFT (ex. it’s name, description, image, etc).

When would it be used?

There are tons of use cases for Dynamic NFTs. As a video gamer myself, I can see Dynamic NFTs being used across a multitude of games. For example, a game where you upgrade your weapon if you purchase a power-up, or adding an extra stat to your character if you use a super-strength potion.

Additionally, Dynamic NFTs can be used to excite communities who work together on certain achievements or goals. For example, everyone’s NFT gets leveled up if a certain donation goal is reached in the community.

How to deploy your own Dynamic NFT.

I have created a repository on GitHub that contains all the code needed to deploy your own Dynamic NFT Contract, as well as the transactions and scripts necessary to mint NFTs, upgrade NFTs, and view NFTs in a user’s account:

https://github.com/jacob-tucker/dynamic-nft-standard

By following the README.md file, you will be able to deploy your own Dynamic NFT contract to a local emulator. Or, you can read the steps below.

Step #1: Install Flow CLI

In order to deploy our Dynamic NFT Smart Contract, you must install the Flow CLI so we can run special Flow commands on our computer.

Follow these steps to install the Flow CLI.

Step #2: Start our Emulator

In a terminal window, run:

flow emulator start -v

Step #3: Deploy our Dynamic NFT Contract & Minting our NFT

In a second terminal window, run:

flow project deploy
flow transactions send ./transactions/setupAccount.cdc
flow transactions send ./transactions/mintNFT.cdc 0xf8d6e0586b0a20c7 "Weak Weapon" "This is the weakest weapon you can own" "Random CID" {}

First, this will deploy our contract to a local Flow emulator that we have running on our computer from Step #2.

Second, it will set up an account to be able to hold an NFT Collection that will be filled with Dynamic NFTs. On Flow, you must set up an NFT Collection inside a user’s account if they are to store NFTs.

Third, we will run a transaction to mint a Dynamic NFT. We pass in some dummy data.

Step #4: View Our Minted NFT

In the second terminal window, run:

flow scripts execute ./scripts/getNFTs.cdc 0xf8d6e0586b0a20c7

This will allow us to read the metadata of the new Dynamic NFT we minted in Step #3.

Step #5: Update Metadata on our Dynamic NFT

In this use case, only an Admin should be able to dynamically update metadata inside our NFT.

In this case, during Step #3 when we deployed our contract, it actually gave what’s called an Administrator resource to the service account on our emulator.

The account with that has the Administrator resource would use the transactions/updateNFTMetadata.cdc transaction to do this. You pass in the NFT's id as well as the current owner of the NFT, and pass in a new name, description, thumbnail, and metadata dictionary. This will automatically update the NFT owned by the current owner with the specific id to that new metadata.

In your second terminal window, run:

flow transactions send ./transactions/updateNFTMetadata.cdc 0xf8d6e0586b0a20c7 [INSERT THE NFT ID FROM "How to Update Metadata" Section] "Strong Weapon" "This weapon is the next strongest weapon after the Weak Weapon." "Random CID" {}

Now follow Step #4 again to see the NFT's updated metadata.