How flare-foundation/flare-hardhat-starter works
Project Type and Purpose
• This is a blockchain development starter kit built on Hardhat for the Flare Network.
• It provides a set of example Solidity contracts under /contracts and corresponding TypeScript scripts under /scripts to compile, deploy, and interact with those contracts.
• It is not a traditional full-stack web application; rather it’s a developer toolkit (an SDK/templates project) for writing, testing, and deploying smart contracts and oracle-based services on Flare.
File Structure Analysis
• Top-level files:
• .env.example / .env – environment for private keys and API keys
• hardhat.config.ts – Hardhat configuration listing Flare networks, compiler settings, plugins
• package.json, tsconfig.json, linter and prettier configs
• Directories:
• contracts/ – Solidity smart contracts organized by feature: crossChainFdc, crossChainPayment, customFeeds, fassets, fdcExample, proofOfReserves, weatherInsurance
• scripts/ – TypeScript scripts that compile/deploy/interact grouped the same way as contracts plus some utilities
• utils/ – shared TypeScript helpers (e.g. network.ts)
• No web-UI frontend; interactions occur entirely through Hardhat scripts and plugins.
README Insights
• Emphasizes compilation (npx hardhat compile), testing, and deployment to Flare testnet/mainnet via Hardhat.
• Mentions use of Flare’s official periphery contracts package for mocking and integration.
• Encourages a clean starter approach: remove example contracts and scripts to start a new project.
Main Components
a. Smart Contract Layer
• Contracts in /contracts/* (e.g. FDC, payment, oracle feeds, insurance modules)
• Artifacts generated by Hardhat
b. Script/CLI Layer
• TypeScript scripts in /scripts/* using Hardhat Runtime Environment (HRE)
• Utility modules in /scripts/utils and /utils
c. Hardhat Engine
• hardhat.config.ts plugin system (Ethers.js, Waffle, Defender, etc.)
• Compilers and task runners
d. Network/External Services
• Flare blockchain nodes (Testnet/Mainnet RPC endpoints)
• Oracles or external data sources consumed by customFeeds and weatherInsurance
• Flare periphery contracts package (npm library)
e. Environment & Configuration
• .env for private keys, API keys
• Network parameters (URL, chain ID) in config files
Relationships and Data Flows
• Deployment flow: Script → HRE → compile → contract artifacts → RPC endpoint → deployed contract
• Interaction flow: Script imports deployed contract addresses → HRE → executes read/write calls → Flare node → blockchain state
• Oracle flow: Scripts fetch external data (e.g., metal prices, weather) → prepare and submit oracles requests → contracts process proofs/events
• Utilities: network.ts provides network selection and RPC configurations to all scripts.
Architectural Patterns & Principles
• Modular feature grouping (each /contracts/X with matching /scripts/X)
• Separation of concerns:
• Contracts only contain on‐chain logic
• Scripts handle deployment and orchestration off‐chain
• Utils abstract shared behavior (network config, common getters)
• Configuration-driven design: using environment variables and centralized config (hardhat.config.ts)