This repository containts an Ethereum DApp that demonstrates a flight insurance application
CURRENT: live version of contract: ETHERSCAN
These instructions will get you a copy of the FlightSurety.app and lets you run the client on the local machine and deploys your own contract to the test network rinkeby.
Please make sure you've enabled MetaMask extension in your browser and gulp installed.
-
Clone this repository:
$ git clone https://github.com/Userrick/FlightSurety
-
Got to Flightsurety/client/ and install all requisite npm packages (as listed in
package.json
):$ npm install
-
Create a new file in FlightSurety/client/src/blockchain/ with the name migration-secrets.js:
$ touch migration-secrets.js
-
Install truffle-hdwallet-provider in FlightSurety/client/src/blockchain/:
$ npm install
-
Copy the following into it (attention to https://):
const secrets = { address: "YOUR ADDRESS WHICH WILL ALSO BE THE FIRST ADMIN OF FLIGHTSURETYDATA CONTRACT" mnemonic: "YOUR-SEED-WORDS-FROM-METAMASK-ACCOUNT", ENDPOINT: "https://YOUR-INFURA-ENDPOINT_KEY" } module.exports = secrets;
-
Follow this guide to reveal your seed words from your METAMASK account.
a) Be sure to be on the rinkeby testnetwork
b) Copy your seed words from your METAMASK into the respective marked section of the secrets-migration.js file
-
Visit the infura website
a) login or create account
b) create a new project
c) COPY the endpoint from the project to clipboard
d) PASTE it into the respective field in the secrets-migration.js file
-
Now launch your personal flight insurance contracts to the network by following these commands:
$ truffle compile $ truffle migrate --reset --network rinkeby
-
Now launch the client by the following command:
$ npm start
-
Got to Flightsurety/server/ and install all requisite npm packages (as listed in
package.json
):$ npm install
-
Create a new file in FlightSurety/server/ with the name secrets.js:
$ touch secrets.js
-
Copy the following into it (attention to https://):
const secrets = { mnemonic: "YOUR-SEED-WORDS-FROM-METAMASK-ACCOUNT", ENDPOINT: "https://YOUR-INFURA-ENDPOINT_KEY", privateKey: "YOUR-PRIVATE-KEY-OF-METAMASK-ACCOUNT-USED-FOR-REGISTRATING-DEFAULT-ORACLES-AND-ALSO-RESPOND-TO-ORACLE-REQUEST" } module.exports = secrets;
-
Edit the config.js file in Flightsurety/server/ to your needs
Make sure to use the same address as for deploying your smart contract!
-
Install MongoDB from MONGODB
-
Open New Terminal and run:
$ mongod
-
Now launch the server by the following command in a new terminal and wait until every oracle of the 40 are registered:
$ npm run dev
Now you should be able to interact with your contract at LOCALHOST via METAMASK on the rinkeby test network.
If you encounter some issues let me know!
Enjoy!
- Make sure to search for all the comments in the FlightSuretyApp and FlightSuretyData contract marked with ///@dev and comment the direct below require statement out.
- Ethereum - Ethereum is a decentralized platform that runs smart contracts
- Truffle Framework - Truffle is the most popular development framework for Ethereum with a mission to make your life a whole lot easier.
- truffle-hdwallet-provider - HD Wallet-enabled Web3 provider. Use it to sign transactions for addresses derived from a 12-word mnemonic.
- NODE + NPM
- MONGODB - The database for modern applications
- REACT - A JavaScript library for building user interfaces
- REACT-Bootstrap - The most popular front-end framework Rebuilt for React.
- Truffle v5.0.22 (core: 5.0.22)
- Solidity v0.5.8 (solc-js)
- Node v12.4.0
- Web3.js v1.0.0-beta.37
Starter code was provided by Udacity