Dynamic NFT (ERC721) smart contract created using Ethereum, Solidity & Chainlink.
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 thetokenURI(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. UsetokenURI(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.
- JavaScript
- Solidity
- Npm
- Node.js (14.0.0)
- Hardhat
- Ethers
- Chainlink
- OpenZeppelin
- Chai
- Metamask extension installed in chrome.
- Alchemy account and API key.
- AccuWeather account and API key.
-
Clone the repo
git clone https://github.com/benmoussa96/dar-blockchain-test.git
-
Change into repo root directory
cd dar-blockchain-test
-
Install dependencies
npm install
-
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": "..." }
-
Compiling the contract:
npm run compile
-
Testing the contract:
npm run test
-
Launching a hardhat node:
npm run node
-
Deploying the contract to the Goerli Testnet:
npm run deploy-goerli
-
Fund the contract with LINK Tokens and have fun!!