Git Product home page Git Product logo

chainlink-dynamic-nft-alchemy's Introduction

REPOSITORY FOR THE CHAINLINK LABS MODULE IN ALCHEMY'S ROAD TO WEB3 DEVELOPER PROGRAM

TABLE OF CONTENTS

Project Description

Tutorial on youtube Written tutorial version

This project mints Dynamic NFTs that change based on the market price of an asset pair (for example, the BTC/USD asset price). When prices go up, its a bull trend and when the go down its a bear trend. We run Chainlink Keepers to have our smart contract automatically called at specified intervals so that on-chain logic checks the Chainlink Price Feed to see if there has been a change in price. Accordingly the minted NFTs dynamically alternate between the images below.

The entire project is designed for ease of use by those new to Web3 and can be run from a Remix in-browser IDE and network environment.

Expanding your skills

Though this code base is minimally designed for use in Remix, it's always great to push yourself to expand your skills! We encourage you to learn and use more advanced tools like Hardhat and Truffle by

  • cloning the Hardhat Starter Kit or the Truffle Starter Kit repos,
  • dropping the smart contracts you write for this project into those repos,
  • adapting the deploy scripts, interaction scripts and tests as scaffolded in those starter kits.
  • Note : those starter kits include all the configuration you need to consider for deploying to test networks and also for Ethereum main nets. Be sure to read through the READMEs there to get a sense of what needs doing!

You can check out videos from the Chainlink Spring 2022 Hackathon on YouTube, especially the trainings on

You can even dig into Chainlink Smart Contract Examples to find more clever ways of extending your code!

TOOLING REQUIREMENTS

All you need to run this code is the Remix IDE running in your browser and a Metamask wallet. While this repo includes mocks for you to "mimic" Chainlink oracle services, for your Assignment you will need to deploy to the Rinkeby test network.

When on test networks you will need test Ether and test LINK tokens in your Metamask wallet.

โš ๏ธ Be sure to use only test ethereum accounts in Metamask when developing. You don't want to lose or spend real money!

Branches

This repo is organized in "layers". Each branch below represents the subsequent stage of the code buildup.

  • main: has the starting code and the IPFS picture and json files. Also has the Dynamic NFT (ERC721) smart contract code.
  • price-feeds has the code that adds Chainlink Data Feeds logic and functionality along with the implementation of the Keepers interface so that our NFT Contract is Keepers compatible. It also has the mock Price Feeds smart contract called MockPriceFeed.sol which can be used to mock what calls to the actual Chainlink price feed would do. An example of what the return value from a price feed looks like is: int256 3034715771688 which denotes the price up to 8 decimals.
  • randomness contains the code for the assignment.

Assignment

Update the NFT contract code to make the following happen:

  • track the current market trend (hint: use an enum like enum MarketTrend{BULL, BEAR})
  • update performUpkeep so that it tracks the latest market trend based on the getLatestPrice() and if there is a price change, it calls another function (eg requestRandomnessForNFTUris()) that initiates the process of calling a Chainlink VRF V2 Coordinator for a random number.
  • implement fulfillRandomWords() as per the VRF documentation
  • test thoroughly in-browser, and then deploy to either Rinkeby or Polygon Mumbai test networks. We suggest you only use Rinkeby or Polygon Mumbai as you may have a smoother experience

A suggested implementation of the assignment is in the branch called randomness.

Viewing NFTs on Opensea

Once deployed to one of the testnets mentioned above, your NFT should be viewable on Opensea testnets. Note: if the dynamic NFT is taking time to change on OpenSea that's not unusual. In that even just call your contracts tokenUri() method and check what IPFS URI is being pointed to. If it changes, then your code is working but OpenSea's cache may not show the new image for a while, even if you do a force-update on Open Sea. However, you should see the name of the NFT update even if the image is lagging.

Thank you!

Thank you for being curious and hungry to participate in the new Web3 movement! If you have any questions, reach out on Twitter or tag me on LinkedIn.

[Updated 14 June 2022]

Added basic testing on the main branch to test deployment of the Bull&Bear.sol NFT contract. Tests use mocha, chai, , ethers and waffle. Please do yarn install using the updated package.json to pull down the developer dependencies needed to run the tests.

To run tests, from the project root, please run yarn hardhat test.

chainlink-dynamic-nft-alchemy's People

Contributors

zeuslawyer avatar toine08 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.