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 scaffolding (using HTML, CSS and JS) and server app scaffolding.
To install, download or clone the repo, then:
npm install
truffle compile
To run truffle tests:
truffle test ./test/flightSurety.js
truffle test ./test/oracles.js
To use the dapp:
truffle migrate
npm run dapp
To view dapp:
http://localhost:8000
npm run server
truffle test ./test/oracles.js
To build dapp for prod:
npm run dapp:prod
Deploy the contents of the ./dapp folder
To an esier navigation, the page is divided in different sections:
- Airline actions
- Flight actions
- Passenger actions
- Oracle actions
- Logs
Every time an action is performed, a log will be displayed at the bottom "Logs" section.
- Open site with Metamask enabled and with contract owner account selected. Operational status should be displayed as true at logs (refresh page otherwise).
- Add funds to activate the account. Minimum of 10 eth are required.
-
Register an airline introducing account address and name. Then, an OK message will be logged and it will be added to airlines combobox When registering the fifth airline, voting system starts and a log wil warn about it. Once the airline has 4 votes, it will be added as previous ones.
-
Select in Metamask the new airline account.
-
Add funds to the new airline.
-
Register a flight introducing Flight Code and Destination. Click on the flight code to copy on clipboard.
- Switch in metamask to a third account, to be used as a passenger.
- Paste or write flight code and set the amount of ethers we want to pay for a flight insurance, and then click on "Buy".
- Oracles working on server will return a specific status. By default, it is "ON TIME", but it can be changed clicking on Oracle Simulation status buttons. Click on "LATE AIRLINE" to be able to finish this circuit.
- Paste flight code on Oracles sections Flight Number box, select correct airline in dropdown menu and click on "Submit to Oracles". After few seconds, flight status will be updated in the flights display panel.
- With the passenger account selected in Metamask, click on "Check credit". It will show payed insurance amount multiplied by 1.5.
- Clicking on "Claim Credit" passenger will withdraw the credit and it will be added to its account.
- How does Ethereum work anyway?
- BIP39 Mnemonic Generator
- Truffle Framework
- Ganache Local Blockchain
- Remix Solidity IDE
- Solidity Language Reference
- Ethereum Blockchain Explorer
- Web3Js Reference
- Node.js v6.14.4
- Solidity v0.4.25
- Truffle v5.1.27
- Ganache v6.10.0-beta.2
- truffle-hdwallet-provider v1.0.2
- Web3 v1.2.6