ChainFlight is a decentralized platform built on Ethereum that offers flight delay insurance policies. It utilizes smart contracts and Chainlink Any API to automate policy management and payouts based on real-time flight delay data retrieved from external APIs.
This platform leverages blockchain technology to provide decentralized, transparent insurance for flight delays. Through the use of smart contracts, payouts are automatically triggered when a flight delay is detected, ensuring a trustless, reliable, and transparent claims process.
- Blockchain-Powered Insurance: Policies are managed on the Ethereum blockchain using smart contracts, ensuring a transparent, trustless system.
- Automated Payouts: When a flight delay is detected via Chainlink Any API, payouts are triggered automatically without the need for manual approval.
- Real-Time Data Integration: Flight delay data is fetched from external APIs via Chainlink's oracle system, ensuring reliable data.
- Flexible Policy Management: Users can create, track, and manage insurance policies directly on-chain.
- Getting Started
- Project Structure
- Running Locally
- Deploying Contracts
- Smart Contract Overview
- Testing
- Contributing
To get started with ChainFlight, follow the instructions below to set up your environment and interact with the smart contracts.
Ensure you have the following installed:
- Node.js (v14 or later)
- npm (v6 or later)
- Hardhat (v2 or later)
- Solidity (v0.8.x or later)
- A local Ethereum network (e.g., using Ganache)
To install all dependencies required for the project:
npm install
contracts/
: Contains the Solidity smart contracts.FlightDelayAPI.sol
: Main contract for interacting with flight delay data.InsurancePolicy.sol
: Manages insurance policy logic, including claims and payouts.MockLinkToken.sol
&MockOracle.sol
: Mock contracts used for testing (Chainlink tokens and oracles).
scripts/
: Contains deployment scripts.deploy.cjs
: Script to deploy the smart contracts to a local or live Ethereum network.
router/
: Contains backend logic in Node.js.auth_users.cjs
: Manages user authentication.external-adapter.cjs
: Handles fetching flight delay data from external APIs.policiesdb.cjs
: Manages insurance policy data in the database.
test/
: Contains unit and integration tests for the smart contracts.InsurancePolicy.test.cjs
: Tests for theInsurancePolicy.sol
contract.
Follow these steps to run the project locally.
git clone https://github.com/yourusername/ChainFlight.git
cd ChainFlight
npx hardhat compile
Ensure you have a local Ethereum network running (e.g., with Ganache), then deploy the contracts:
npx hardhat run scripts/deploy.cjs --network localhost
Once the contracts are deployed, start the Node.js backend:
npm start
You can deploy the smart contracts to Sepolia testnet by editing the hardhat.config.cjs
to include Sepolia network configurations.
To deploy to Sepolia, ensure you have set up your private keys and Chainlink credentials in the .env
file.
npx hardhat run scripts/deploy.cjs --network sepolia
This contract interacts with an external API to fetch flight delay data via Chainlink. It is responsible for receiving and validating flight status updates that will trigger insurance payouts.
Handles the core insurance logic, including the creation, management, and payouts of policies. When a flight delay is detected, this contract will execute the payouts to eligible users.
Unit tests for the InsurancePolicy
contract can be run using Hardhat's built-in testing framework:
npx hardhat test
This will run the tests located in test/InsurancePolicy.test.cjs
to ensure that the insurance logic, policy creation, and payouts are functioning correctly.
For more details on how to test using Remix IDE, refer to the REMIX_TESTING.md file.
Contributions are welcome! Please fork this repository and submit pull requests with your changes.
This project is licensed under the MIT License.
- Add More Tests: Expanding the test coverage for edge cases and other contracts.
- Integrate Frontend: Develop a frontend to allow users to interact with the insurance policies.
- Improve Security: Conduct audits and improve the security of the smart contracts.