Skip to content

Ethereum Smart Contract for E-Cert DAap app. It is built with solidity, an object-oriented programming language for writing smart contracts.

License

Notifications You must be signed in to change notification settings

Dynamic-Flakes/E-Cert-Dapp

Repository files navigation

E-Cert-Dapp

Introduction

Checks:

  • Only educator can register certificates and issue certificates.
  • The certificate which is to be issued, must be registered first.
  • No single user can register twice.
  • No hash of a certificate can exist more than one

Actors:

There are 3 types of actors the system provides support to:

  • Educator: This is the certifying authority, which registers new certificates, then issues the desired student that certificate.
  • Student: This is the recipient of the certificate. It first registers itself in the system. He request for a certificate after a course is finished and the stored on-chain
  • Verifier: This can be any anonymous user, who wants to verify the student's certificate.

Events:

Events are the logs of all the transactions done in the blockchain. So for every function of the smart contract, we log its details in events. Our system tracks these events:

  • LogNewHashStored: Ths event is triggered when a hashed is stored on-chain. It logs details of every hash added to an address registered.

Process Flow:

  • Issuing: This is the process of receiving and generating certificate hash on the ui. Certificate will be received from the frontend, a unique hash (ie that represents the fingerprint of the certificate) will be generated by the hash-generator function

  • After hash generation, a call to a function on the smart contract to ensure this hash is stored on the blockchain will be made

  • When this occurs, the UI also sends an email to the student with a hash of the certificate.

  • Sharing: this is the process by which the student of a certificate shares that certificate with a third-party.Simple way to share is that once given a hash to the student, the student can send his or her certificate to their verifier via mail

  • Verification: this is the process by which a third-party verifies the authenticity of the certificate.

  • Once the verifier receives the student certificate, they upload it to the UI for verification. The frontend calls on a function in the smart contract in order to verify that the hash was authenticated by the university.

  • The true/false boolean result is then displayed on the frontend, in the verifying window

Alt text

Milestone 1

    1. Get certificate data and sub-functions
    1. Verify certificate data and sub-functions.

Milestone 2:

    1. Manage key and sub-functions
    1. Integration with e-learning platform

Milestone 3:

    1. Manage wallet and sub-functions
    1. Deployment to permanent web server I will provide.

Technology stack:

Set Up

Install truffle

  • Run the command npm install -g truffle
  • Git clone the E-cert-Dapp repo
  • Cd into the directory and run yarn install
  • Run yarn run compile to compile the smart contract
  • Run yarn run migrate to migrate the contract. truffle deploy is an alias for truffle migrate. They both do the same thing.
  • Run yarn run console to interact with the smart contract on the ganache ethereum blockchain

Install Ganache

  • Go to https://truffleframework.com/ganache and download a version dedicated to your operating system.
  • Install by a double click, then run.
  • Ganache runs with default values which should be the same or similar to these on-screen. The crucial part is a section defining RPC Server.
  • Leave it running.

Install Nodejs

  • To download Nodejs, navigate to navigate to https://nodejs.org/en/download/ and click the version that suits your machine
  • After downloading it, click the installer to get it installed on your machine
  • Verify installation by running the command on your CLI node -v
  • You can use npm or yarn for package management

Testing Results

  • Open a terminal and run: truffle test or yarn run test

Alt text

Test Coverage Results

  • Open a terminal and run: truffle run coverage or yarn run coverage

Alt text

Contract deployment gas cost on local network - Ganache

  • Open a terminal and run: truffle run migrate or yarn run migrate

Alt text

Contract deployment gas cost on ropsten network - testnet on infuria

  • Open a terminal and run: truffle run ropsten or yarn run ropsten

Alt text

Contract deployment gas cost fee on ropsten etherscan explorer

  • Open a terminal and run: truffle run ropsten or yarn run ropsten

Alt text

Contract Graph

  • Use Solidity Visual Developer to generate the graph for the contract

Alt text

Contract UML Diagram

  • Use Solidity Visual Developer to generate the UML with PlantUML embedded

Alt text

CertificateRegistry:

  • This is the main contract. The contract handles the generation and verification of certificates as shown below.

  • storeHash() — generates a certificate by calculating a hash of the student name and details. Can be called only by the owner. Emits a certificate generation event with the timestamp. The issuer puts the certificate on the blockchain by storing it in the global variable records by passing records[certificate] = msg.sender.

  • owningAuthority() — returns the address of issuer/authority.

  • verifyCertificateData() — calculates a hash of the student name and details, and checks if the contract is on the blockchain. Can be called by anyone.

Since CertificateRegistry inherits from Ownable, Ownable will be deployed together with CertificateRegistry.

Interact with the contract on your local development network

  • run yarn console in your Truffle console, create an instance of the deployed contract

  • Declare the contract owner: let instance = await CertificateRegistry.deployed()

  • Declare the contract owner: let owner = await instance.owningAuthority()

  • Issue the certificate: let result = await instance.storeHash("0x94f3e4c13989c51472ce78354b5205c5411f82e83c745b6f675e0c9aeb8ab4d1", {from: owner})

  • Run result.logs to view the full certificate details.

  • Run the certificate verification: let verify = await instance.verifyCertificateData("0x94f3e4c13989c51472ce78354b5205c5411f82e83c745b6f675e0c9aeb8ab4d1", {from: owner})

About

Ethereum Smart Contract for E-Cert DAap app. It is built with solidity, an object-oriented programming language for writing smart contracts.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published