/blockchain-certification

Generation and validation of certificates using ethereum blockchain

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

Certificate Generation and Validation Using Blockchain

Docker Build Docker Build Status Join the chat at https://gitter.im/yogdaan/blockchain-certification
Deploy

Built using Ethereum on local blockchain setup and deployed on Rinkeby test network.

Contract deployed at 0x89c34c6a0d4c7587e9120a533757f380f4676887
RPC Network Rinkeby Test Network

Steps to set up local development environment

Setting local blockchain

  1. We need to install CLI version of Ganache.

    npm install -g ganache-cli

    Ganache provides us our personal local blockchain network which we can use to develop our blockchain application. It also gives temporary test accounts with fake ethereum which we can use to run our apps. We need to start the RPC server before running our application.

  2. To start the RPC server run the command

    npm run ganache

    Windows user will need to run this command in separate command prompt or terminal.

  3. Deploy the smart contract to the local blockchain.

    npm run contract-deploy

The above 2 steps need to be run everytime you are running the project.

Setting local database

MongoDB server should be running as a background Process

  1. Open mongo in terminal using command mongo

  2. Then change the db using command

    use certification
  3. Then set DB user and password with the following command

    db.createUser({
      user: "<YOUR USER NAME>",
      pwd: "<YOUR USER PASSWORD>",
      roles: [{ role: "dbOwner", db: "certification" }]
    });
  4. Include these username and password in the .env file.

Now we can start the server

npm start

Deploying Smart Contract

The contract can be deployed in any test networks. We are using Rinkeby test network with help of truffle.

  1. First of all we need to have a metamask account. When we create an account in metamask a mnemonic is given t+o us. You can read how to get a mnemonic here.

  2. After that create a project in Infura. This will help us to use rinkeby network through infura.

  3. You will get an endpoint like this https://rinkeby.infura.io/yourapikey.

  4. Create a .env file in root directory and paste the previously genrated mnemonic and the endpoint URL in that. An example is also provided in .env.example file.

    For running in development environment and to use local blockchain network, use the LOCAL_ENDPOINT variable and replace the URL with your own local URL (These default values are filled already and shouldn't be changed unless until RPC server running on different port)

  5. Now you can deploy the smart contract using a single command:

    npm run deploy
  6. You will get a contract address of newly generated contract. Save this for further uses.

Testing app

To test the app run the command truffle test. RPC server should be running to run the tests.

Useful reads


Developers
Saurabh Thakur st