This is a simple decentralized application built using Ethereum blockchain and Vue JS for the front-end.
Selected members of an institution sign degrees.
After enough signatures have been gathered for an individual, he is considered a graduate.
Anyone with this person's details can verify he is a graduate.
- NPM version 5.8.0
- TRUFFLE verson 4.1.5
- Ganache or your private network
- Metamask
Main skeleton of the app was found here
-
sudo npm install truffle -g git clone [email protected]:catman85/UNIPI-Smart-Degrees.git cd UNIPI-Smart-Degrees/
-
Start ganache UI for windows.
Click the little settings icon on the top-right.
Under the workspace tab add your truffle project file. UNIPI-Smart-Degrees/truffle.js
Save and your workspace and launch it.
-
Open the terminal in the folder UNIPI-Smart-Degrees/ and run the command:
truffle console --network ganache
- If ganache is running you should be inside the truffle console; now run the following command in the truffle console:
> migrate --reset --compile-all
- If the migration was successful, copy the file ~/UNIPI-Smart-Degrees/build/contracts/Degrees.json (which contains the "abi") into the folder ~/UNIPI-Smart-Degrees/frontend/src/assets/
- Open another terminal in the folder UNIPI-Smart-Degrees/frontend and run the command (without sudo):
npm install
- Once all the dependencies are installed run the command:
npm run serve
If everything went fine, the terminal will display a message similar to:
DONE Compiled successfully in 5166ms 15:54:53
Your application is running here: http://localhost:8080
- Open the browser, go to the URL shown by your terminal and play with the DApp!
NOTE: You can use the same seed in Ganache and Metamask for convenience.
To create more accounts (pairs of public and private keys) in MetaMask: (they all derive from the same seed.)
- Click the favicon (your account image) on the top right of your MetaMask pop up
- Click βCreate Accountβ
- A new MetaMask account is created
- Click βeditβ above the account name to change it.
- Make sure the newly created account is matching the account generated by ganache (have a look in ganache's Account tab).
- Replace the addresses in the constructor from the contracts/Degrees.sol file, with your own.
constructor() public {
owner = msg.sender;
addProf(address(0x4B0897b051...),"mf");
addProf(address(0x583031D111...),"kanatas");
...
}
OR use this seed: "save lyrics plate shrimp warm credit december salon velvet announce outer hamster"
- fire up your ganache workspace and then from the project directory run,
truffle console --network ganache
>migrate --reset --compile-all
>let instance = await Degrees.deployed()
>let accounts = await web3.eth.getAccounts()
>accounts
>instance.professors
>instance.getProfessorIndex({from: accounts[0]})
>instance.signGraduation("a",{from: accounts[0]})
>instance.verifyGraduation("a")
>instance.signGraduation("a",{from: accounts[1]})
>instance.verifyGraduation("a")
fire up ganache and then,
truffle console --network ganache
> test --reset-all
It is very convenient to share the same accounts in Ganache/MetaMask from multiple development workstations. To achieve this you need to:
- Generate a new seed with metamask. Once you have that seed,
- Create a new workspace with Ganache:
- Under Accounts&Keys enter the menomonic you generated with MetaMask.
- Under Workspace add the UNIPI-Smart-Degrees/truffle.js project file.
- Save your Workspace and launch it.
- finally run
truffle console --network ganache
and you should be inside the truffle console. - When developing from a new machine, follow the same steps from 1.
NOTE the /frontend/build/ directory is needed for npm install && npm run serve
- Open the MetaMask addon and find where it says Main Ethereum Network
- Click that and select Custom RPC
- Give your test net a name and now for the important part.
- Look at the Ganache GUI, there should be a RPC Server indication.
- Copy and paste that url to the MetaMask field and refresh your frontend.
- Boom, you are connected!
Open Ganache UI
Make sure you have installed expect and xterm in your machine.
apt-get install expect xterm
Make sure the start.sh script has execution privilages.
chmod +x start.h
After opening the Ganache GUI, open yout browser, sign in to MetaMask and connnect to Ganache's RPC network.
Then execute:
./start.sh
This little script will :
- connect truffle with ganache
- test your contracts
- copy the compiled contracts
- run the frontend part of the app
Open Ganache UI.
Make sure you have installed expect in your machine. And you are located in the project's root directory
apt-get install expect
After opening up Ganache UI,
run:
expect trufflexp.exp
After the first command is done, in another terminal:
cp build/contracts/Degrees.json frontend/src/assets/Degrees.json
Then open your browser, sign in to MetaMask and connect to Ganache's RPC network.
Finally, in another terminal:
cd frontend/ && npm run serve