FlightSurety is an Ethereum DApp to manage flight insurances.
Airlines form a consortium:
- Providing a funding of at least
minFund
is required to join - Starting from 4 airlines registered, consensus of 50% is required (votes of half of the registered airlines) for new airline registration
- Consensus is not required to register flights
They can
- Register other airlines.
- Can register flights
- Withdraw the amount credited to them following flight ticket purchases by passengers.
Passengers can:
- Book flights that have been registered by airlines.
- Subscribe insurance
- This allows them to get reimbursed 1.5 x their insurance amount if a flight is delayed due to the airline's responsibility.
- This credited amount is not transferred automatically but has to be withdrawn.
The oracles inform the smart contract about the status of a flight.
Flight status is requested by submitting a corresponding request to the oracles.
As soon as 3 oracles provide concurring opinion, the flight status is updated accordingly.
Oracles are simulated: they generate a random status code on the server side.
Data (flights, passengers, insurance amounts, airlines...) has been separated from application logic,
resulting in two separated contracts: FlightSuretyApp and FlightSuretyData.
This offers the following benefits:
- a new 'App' contract can be deployed in the case of business rule changes (different oracle registration fee, funding fee, etc..) while the state of the data contract is kept.
- ensures modularity
-
Clone/download repository
-
Install dependencies:
yarn
-
Start local blockchain:
yarn anvil
-
Deploy contracts:
yarn deploy
-
Start server:
yarn start:server
(available onhttp://localhost:3001
)
APIpath method request response /flights GET List of registered flights /flight/:key GET flight /response/:key GET status code /flight-key POST { flightRef: string, from: string, to: string, takeOff: number } flight key hash -
Start UI:
yarn start:ui
((available onhttp://localhost:3000
))
- Foundry: Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
- CRUD pattern in solidity