LCP

In today’s world, NFTs are being used as a form of digital art or collectibles, that exist on the blockchain. The most common form of NFTs include images, videos, and audio files. These NFTs are called Static NFTs as they stay in the same state and do not change their state in the future.

What are Dynamic NFTs?

Going beyond Static NFTs comes Dynamic NFT or DNFT. These NFTs change their state based on external factors. For instance, an in-game avatar can change its clothes based on the weather outside in the real world or a game changes its avatar according to the time of the day and the mission they are on.

Illustration of evolving NFTs that change over time based on external factors.

How does a DNFT work?

For all of you, who do not know how a static NFT works, we upload the asset on decentralized storage called IPFS, get the IPFS URL, and store it in its metadata. This NFT has its unique token id and can be minted using this token id by paying the respective price.

Dynamic NFTs work in a similar fashion. DNFT have multiple assets and their respective metadata linked to them. Initially, the DNFT will have an asset and its metadata assigned to it during the contract deployment. A DNFT has this dynamicity since we can change the metadata of the NFT, which is currently being displayed in the marketplace. In our example, over the period, when the weather changes, the metadata will change according to the respective weather. So when the winter hits, the NFT will have winter clothes, and in summer, it will have summer clothes, and so on.

Diagram depicting the process of Dynamic NFTs changing state through metadata updates.

How to create your DNFT?

To create a DNFT, we are going to use NFTPort. NFTPort provides REST APIs, which makes it easier to create your DNFT. The only prerequisite is that you need an API key, that can be obtained from NFTPort for free.

You can also view the codes on GitHub.

Follow the below steps to create your first-ever DNFT:

1. Deploy the smart contract

The very first step is to deploy the smart contract for your NFT. You need to send your preferred chain, name, and symbol for your NFT. Along with that, you need to pass your wallet address and make sure that the metadata_updatable key is set as true.

Screenshot of the API request to deploy a smart contract for DNFT creation.


After the contract has deployed on the selected Blockchain, you will get a transaction_hash in the response. We are going to use this in the further steps.

2. Get the contract address

After deploying the smart contract, the next step is to fetch the address of the deployed contract. We will use the transaction_hash from the previous API to get the contract address and pass the chain on which the contract has been deployed as a request parameter.

Screenshot of the API response showing the contract address after deployment.


This API will return the contract address of our NFT.

3. Upload assets to IPFS

Next, we will upload all the required assets to the IPFS. In this step, we are going to upload each and every NFT asset separately on the IPFS.

Screenshot of the API request for uploading DNFT assets to IPFS.


The above API will return an IPFS URL with key ipfs_url. Make sure you save all the unique IPFS URLs for the assets because it will be required in the later steps.

4. Creating and Uploading NFT Metadata

Once we have uploaded our NFT assets to the IPFS, the next step is to create metadata for the respective NFTs and upload them over the IPFS to use in our contract. Get the IPFS URL for each asset and call the below API accordingly.

Screenshot of the API request for creating and uploading metadata for DNFT.


Once you have called the above API for an NFT, you will get a metadata_uri in the response. Keep the metadata_uri with you for all the NFTs.

5. Mint NFTs

Now that our contract has been deployed and all of the metadata have been uploaded to the IPFS, we will mint the NFT to our address. For this, you need the deployed contract address, IPFS URL for metadata for the initial state of the NFT, and the minting address to which the NFT will be minted.

Screenshot of the API request for minting a DNFT with initial metadata.

Once the transaction goes through, you will be able to see this minted NFT in Opensea. Just in case it is not visible, it is possibly hidden and can be restored from the Hidden NFT section of Opensea.

Visual representation of a DNFT called Dynamic Island during daytime.

6. Get the Token ID

Once the NFT has been minted, we require the Token ID of the NFT to update the metadata_uri. To get the ID, we need the transaction_hash from the previous steps and the chain in which the contract was deployed.

Screenshot of the API request to get the token ID of a minted DNFT.


The above API will give you the Token ID for the minted NFT.

7. Update the Metadata

Now, when we need to update the NFT due to any external factor like weather change or time, we will call the below API, which will modify the metadata URI of the NFT on the Blockchain. We will need the Token ID, contract address, the new metadata_uri, and the chain of the NFT. The API has necessary checks to make sure that you do not update the same metadata again.

Screenshot of the API request for updating metadata of a minted DNFT.


After the transaction goes through, you will see that the NFT on Opensea has been replaced with the NFT whose metadata we have used in the API. Make sure to click the Refresh Metadata button if the new NFT is not visible after some time.

Visual representation of the DNFT Dynamic Island during evening.

There are many ways in which this dynamicity can be achieved. One way of doing this is by creating a lambda function on AWS and adding the business logic over there. Once the lambda is deployed, we can set up an EventBridge Trigger which will call the lambda function based on the rules provided.

Endnote

To summarize, DNFT is a non-fungible token that can change or mutate over time based on external environmental factors. It is basically a change in the metadata of the NFT triggered by the smart contract, creating which has been explained in the step-by-step process.

LaMelo Ball and Beeple are such examples of DNFT. It certainly has an upper hand over Static NFTs because of its dynamicity nature, and we can expect a lot of them in the near future.

Head over to our GitHub Repository and create your own DNFT.

We, at Seaflux, are Blockchain enthusiasts who are helping enterprises worldwide. Have a query or want to discuss Blockchain projects? Schedule a meeting with us here, we'll be happy to talk to you.

Jay Mehta - Director of Engineering
Jay Mehta

Director of Engineering

Contact Us