[Chainlink] How To Build Dynamic ERC-721 NFTs Using Three Chainlink Trust-Minimized Services
Dynamic NFTs are fun and interesting in their own right, but they are also useful for developing a better technical understanding of smart contract technology, improving software design skills, and learning how to use exciting new tools that are widely used in industry.
In this project we are going to build a dynamic NFT that doesn’t just update but does so randomly—its image will change based on the price of an asset, which will be obtained from Chainlink Price Feeds. The new image will be selected at random. If the price goes up, one of these images of a bull will appear.
If the price goes down, one of these images of a bear will be shown.
Either way, the actual image is chosen at random.
Achieving true randomness on blockchains, which are inherently deterministic because of the way their consensus algorithms work, is a very hard problem. But it is made easy with Chainlink VRF which is a provably fair and verifiable random number generator (RNG) that enables smart contracts to access random values without compromising security or usability.
The dynamic NFT will respond to market changes automatically, with no need for developers to check prices or trigger NFT changes. This is possible with the help of Chainlink Keepers, which automate the project., So once your NFT is deployed, all you need to do is keep your VRF subscription and the Keepers registry funded with LINK tokens. The smart contract execution and dynamic NFT selection is done in a decentralized manner that is verifiable and cryptographically secure.
Who This Is For
You can complete this entire project in the browser-based Remix code editor. You’ll find the Github repo for this project here—each branch in the repo represents a stage in the project.
Here are the stages for building the project:
- Build the baseline ERC-721 token. We use the OpenZeppelin Wizard to generate audited library code for this. You can follow this step in the main branch of the reference repo.
- Add the Chainlink Keepers implementation and connect to a Chainlink Price Feed to track a specific asset’s price. You can follow this step in the price-feeds branch of the reference repo.
- Add verifiable randomness so that our dynamic NFT image is chosen randomly from available NFT images. This bit is for you to do as a special assignment to build your skills! You can follow this step in the randomness branch of the reference repo.
Things You Will Learn
This project will teach you:
- How to write, structure, and design Solidity smart contract code
- The fundamentals of ERC-721non fungible tokens and their functionality
- How to use essential tools like Remix, Open Zeppelin libraries, and three major Chainlink services
- How smart contracts interact with each other
You can do this in one of two ways—you can code along with the video tutorial below or follow along with the extended written version of this dynamic NFT tutorial in Lesson 5 of Alchemy’s Road to Web3.
After you’re done, you can expand your fancy smart contract skills even further by building out your own NFT Marketplace using Hardhat and Solidity. This tutorial shows you how to write the logic for a marketplace that allows users to list items, and then buy and sell them and withdraw their earnings.
If you’d like to go even deeper, check out How To Build Dynamic NFTs on Polygon, and how to Build, Deploy and Sell your own Dynamic NFT. You can also read more about how the player-fan experience has been redefined by the LaMelo Ball dNFTs.
Learn more about Chainlink by visiting chain.link or reading the documentation at docs.chain.link. You can also subscribe to the Chainlink Newsletter to stay up to date with everything in the Chainlink stack. To discuss an integration, reach out to an expert. If you’re looking for an end-to-end blockchain developer education, check out blockchain.education.
The post How To Build Dynamic ERC-721 NFTs Using Three Chainlink Trust-Minimized Services appeared first on Chainlink Blog.