FlightSurety is a sample application project for Udacity's Blockchain course.
This repository contains smart contract code in Solidity (using Truffle), tests (also using Truffle), DApp (using HTML, CSS and JS) and server application.
To install, download or clone the repository and install all requisite npm packages (as listed in package.json
)::
npm install
Fix the pragma in node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol
:
pragma solidity ^0.5.0;
Launch Ganache:
ganache-cli --gasLimit 300000000 --gasPrice 20000000000 -a 50 -m "forget chief exist liberty video cash twelve nest grief umbrella panel trumpet"
Your terminal should look something like this:
In a separate terminal window, compile the smart contracts:
truffle compile
Your terminal should look something like this:
This will create the smart contract artifacts in folder build/contracts.
Migrate smart contracts to the locally running blockchain, ganache-cli:
truffle migrate
Your terminal should look something like this:
Test smart contracts:
truffle test
All 28 tests should pass.
To use the Dapp:
npm run dapp
To view the DApp:
http://localhost:8000
npm run server
To build the DApp for production:
npm run dapp:prod
Deploy the contents of the ./dapp
folder
Graded according to the Project Rubric.
- FlightSuretyData contract for data persistence
- FlightSuretyApp contract for app logic and oracles code
- DApp client for triggering contract calls
- Server app for simulating oracles
- Register first airline when contract is deployed
- Only existing airline may register a new airline until there are at least four airlines registered
- Registration of fifth and subsequent airlines requires multi-party consensus of 50% of registered airlines
- Airline can be registered, but does not participate in contract until it submits funding of 10 ether
- Passengers may pay up to 1 ether for purchasing flight insurance
- Flight numbers and timestamps are fixed for the purpose of the project and can be defined in the DApp client
- If the flight is delayed due to airline fault, passenger receives credit of 1.5x the amount they paid
- Funds are transfered from contract to the passenger wallet only when they initiate a withdrawal
- Oracles are implemented as a server app
- Upon startup, 20+ oracles are registered and their assigned indexes are persisted in memory
- Client DApp is used to trigger request to update flight status generating OracleRequest event that is captured by server
- Server will loop through all registered oracles, identify those oracles for which the request applies, and respond by calling into app logic contract with the appropriate status code
- Contracts must have operational status control
- Functions must fail fast - use require() at the start of functions
- Scaffolding code is provided but you are free to replace it with your own code
- How does Ethereum work anyway?
- BIP39 Mnemonic Generator
- Truffle Framework
- Ganache Local Blockchain
- Remix Solidity IDE
- Solidity Language Reference
- Ethereum Blockchain Explorer
- Web3Js Reference
- Truffle v5.0.18 (core: 5.0.18)
- Solidity - ^0.5.0 (solc-js)
- Node v10.15.3
- Web3.js v1.0.0-beta.37
- MIT license
- Copyright 2019 © Thomas Weibel.