Skip to content

[ERC721] Dynamic NFT can poll data from Accuweather (Chainlink Oracles) & visually change according to the data (Chainlink Automation)

Notifications You must be signed in to change notification settings

benmoussa96/chainlink-automation-dynamic-nft

Repository files navigation

Chainlink Automation Dynamic Token

Dynamic NFT (ERC721) smart contract created using Ethereum, Solidity & Chainlink.

Description

The NFT changes it's metadata according to the weather.

  • If the temperature is under 10C, we get a "pensive" emoji 😔
  • If the temperature is over 20C, we get a "grinning squinting" emoji 😆
  • Else we get a "slightly smiling" emoji 🙂

The contract is deployed at: 0x04f5F947296E181Ea92a7cC5796a14a04A47e67f on the Goerli Testnet. This one is already funded with LINK Tokens.

  • First of all, you can mint an NFT using the safeMint(address to) function. You can check that it's URI is set by default to the "slightly smiling" emoji by calling the tokenURI(uint256 tokenId) function.
  • Then, when you call the performUpkeep(bytes calldata) function (with [] as parameter), the contract requests the weather data and uptates the URI of all the tokens. Use tokenURI(uint256 tokenId) again to verify that the URI has changed.
  • Our NFT Contract also implements the Keepers interface so that it is Keepers compatible. This means that it contains custom logic to allow Chainlink Automation to determine when to execute our smart contract functions.

Built with

  • JavaScript
  • Solidity
  • Npm
  • Node.js (14.0.0)
  • Hardhat
  • Ethers
  • Chainlink
  • OpenZeppelin
  • Chai

Getting Started

Dependencies

Installing

  1. Clone the repo

    git clone https://github.com/benmoussa96/dar-blockchain-test.git
  2. Change into repo root directory

    cd dar-blockchain-test
    
  3. Install dependencies

    npm install
    

Compiling and deploying new contract (optional)

  1. Create a secrets.json file at the root of theee project:

    ⚠️ The account that you supply must have test ETH and test LINK on the Goerli Testnet!

    {
        "mnemonic": "...",
        "accountPrivateKey": "...",
        "alchemyApiKey": "...",
        "accuweatherApiKey": "..."
    }
    
  2. Compiling the contract:

    npm run compile
    
  3. Testing the contract:

    npm run test
    
  4. Launching a hardhat node:

    npm run node
    
  5. Deploying the contract to the Goerli Testnet:

    npm run deploy-goerli
    
  6. Fund the contract with LINK Tokens and have fun!!

About

[ERC721] Dynamic NFT can poll data from Accuweather (Chainlink Oracles) & visually change according to the data (Chainlink Automation)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published