Learn how to create dynamic NFTs by following along with this video tutorial:
In this tutorial, you will use the Chainlink Automation Network to help create a dynamic NFT by using the Automation-compatible smart contract provided in the repository.
The demo includes:
- Setting up and funding an upkeep on the Chainlink Automation Network
- Setting up a dynamic NFT and viewing the progression of the NFT on OpenSea.
You can use this example as a starting point for building your own dynamic NFTs and provide more interactive experiences with your collections.
Before you start this tutorial, complete the following items:
- If you are new to smart contract development, learn how to Deploy Your First Smart Contract.
- Set up a cryptocurrency wallet
- To deploy this contract on testnets, ensure the deployer account has testnet LINK. Use the LINK faucet to retrieve testnet LINK.
- Open a new Remix project.
2 Mint an NFT
Once the contract is deployed, you should be able to see more information under the Deployed Contracts section.
At this point, you can mint an NFT. In the field next to safeMint paste your wallet address. Then, click the orange transact button and follow the prompts to confirm the transaction.
After minting the NFT, you can look at the stage of the NFT based on the tokenURIs given in the contract. Enter
"0"in the flowerStage field and click the blue call button. You should see the stage of the NFT.
0in the tokenURI field and click the blue call button to see the corresponding URI for the NFT.
3 Register an upkeep
Copy the contract address and open the Chainlink Automation Interface. Connect your wallet to the network and click the blue button Register New Upkeep. For the Trigger mechanism, select Custom logic. You will prompted to enter your contract address. Paste your address and click Next.
You must fill out the prompts to finish registering upkeep. For the Starting balance (LINK), enter 0.5 for this demo. After entering information, click Register Upkeep. It may take a few moments for this to complete.
4 Trigger the upkeep
Navigate back to Remix. Under the Deployed Contracts section, enter
in the checkUpkeep field and click the blue button. You may see the following text:
upkeepNeeded true. This means that an upkeep will be performed.
While waiting for the upkeep to be performed, copy the contract address to your clipboard and open OpenSea (https://testnets.opensea.io/). Paste your address in search bar at the top of the page. You should be directed to a page with the image of your minted NFT. Click the seed thumbnail to learn more about the NFT.
Navigate back to Remix. Enter
in the checkUpkeep field and click the blue button. If this returns
upkeepNeeded falseyour upkeep should have been performed. Navigate to the Chainlink Automation Interface and select your upkeep to view more details and to confirm that an upkeep was performed. If
upkeepNeeded falseis not returned in Remix, you may have to wait a few minutes and run the checkUpkeep function.
5 Check the NFT stage
Once the upkeep has been performed, navigate to Remix and click flowerStage and tokenURI to see the most recent flower stage and corresponding URI. Navigate back to the information of your NFT on OpenSea. Click the button on the top right to refresh the metadata. You should see the NFT become a bloom.
To see the NFT become a fully blossomed flower, you will have to wait another 30 seconds (or the amount of time you denoted when deploying your contract). After this interval, refresh the NFT's metadata again. You should see a fully blossomed flower. You have now completed the tutorial.
This tutorial used Chainlink Automation to create a dynamic NFT. This was done by deploying an Automation compatible contract in Remix and registering an Upkeep with the Chainlink Automation network. The NFT changed every 30 seconds based on the time interval we inputted when deploying the contract. The final NFT stage was a fully bloomed flower.