Contracts, Dapp and server App to allow an user buys insurance for a certain flight and gets 1.5X in case flight is delayed due to an airline complication
- Ethereum
- Solidity 4
- Ganache CLI
- Truffle
- Mocha JS
- NodeJS
npm install
ganache-cli -m "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat" -a 50
truffle compile
NOTE: All testing was made using DAPP UI to provide a more realistic approach as rubric and project walkthrough allow, specially to provide an environment to test Oracle funcationallity using server express app
truffle migrate
npm run dapp
npm run dapp
Before begin Make sure MetaMask is running and connected to Ganache CLI localhost:8545
- Run ganache blockchain
- Compile and migrate contracts
- Run UI DAPP
- Run Server
- Since a airline is registered at deployment, fund airline with 10 ETH
- Register a new flight and refresh page to fill input fields with registered flights
- Change to another address using MetaMask (although there's extra code to detect the new address without page refreshing, i recommend to refresh)
- Buy insurance (for example 0.5)
- Submit oracle request
- Change to appropriate addresses and claim ETH
In server.js there's a change to allow faster checking for insurance payment, setting fixed oracle responses to code 20 (due to airline)
const statusCode = 20; //(Math.floor(Math.random() * 5) + 1) * 10
This can be changed to adjust to a more realistic approach