How codehawks-contests/2025-05-weather-witness works
Project type and purpose
• Type: Blockchain-based dynamic NFT dApp
• Purpose: Mint ERC721 tokens whose metadata (weather state) is fetched and updated automatically via Chainlink Functions (off-chain code) and Chainlink Automation (Keepers).
File structure
• src/ (on-chain Solidity code)
• WeatherNft.sol (main contract)
• WeatherNftStore.sol (storage, events, data structures)
• functionsSource/ (off-chain JavaScript code for Chainlink Functions)
• GetWeather.js – fetches and parses weather from OpenWeather API
• deploy/
• DeployWeatherNft.js – Hardhat script to deploy contracts & configure initial URIs
• test/ and utils/
• forge tests, JS helpers for secret encryption and contract verification
• config files
• hardhat.config.js, foundry.toml, helper-hardhat-config.js
• CI
• .github/workflows/test.yml runs tests and lints
Extract architectural insights from the README
• Two core on-chain components: WeatherNft & WeatherNftStore
• Two off-chain Chainlink components:
• Functions node running GetWeather.js
• Automation (Keepers) checking heartbeat and triggering updates
• External API: OpenWeather for real-time data
• User roles: NFT Owner (wallet/UI) and Contract Owner (admin parameters)
a. User Layer
• Wallet or Web3 client (e.g., MetaMask, CLI)
• Interacts with smart contract via JSON-RPC
b. Blockchain Layer
• Avalanche Fuji (or any EVM) network node
• Smart contracts: WeatherNft.sol & WeatherNftStore.sol
• Chainlink Keeper Registry & Functions Router contracts
c. Oracle Layer
• Chainlink Functions Node
– Executes GetWeather.js
– Emits callback returning weather data to contract
• Chainlink Keepers Network
– Monitors heartbeats, calls checkUpkeep & performUpkeep
d. External API
• OpenWeather API (geocoding + current weather endpoints)
e. Deployment & Tools
• Hardhat & Foundry for compile, test, deploy
• Deployment script (DeployWeatherNft.js)
• Utility scripts for secret encryption & contract verification
Architectural patterns and design principles
• Oracle Pattern: on-chain contract delegates data fetching to off-chain Functions, uses callbacks
• Event-Driven Automation: Keepers watch for intervals (heartbeats) and trigger updates
• Modular Separation: on-chain (immutable contracts), off-chain (Functions), external services
• Subscription Model: each NFT optionally registers a Keeper subscription funded by a LINK deposit