DEV Community

loading...

CoviDapp with Tezos Blockchain

CoinMonks
We run Coinmonks.
Originally published at Medium on ・7 min read

Tezos is a decentralized, open-source blockchain network that can execute peer-to-peer transactions and serve as a platform for deploying smart contracts.

CoviDapp was our first try to develop a blockchain-based corruptionless distribution for COVID-19 vaccines. The features of this Dapp are:

  • Distribution of vaccines can be done in the systematic top to bottom approach.
  • Hospitals/States with emergency cases/surge in cases can send in requests for more vaccines directly to the higher authority, and their request will be in priority of the higher officials, i.e., hospital requests are a higher priority for State Government Officials.
  • As we all know, in a blockchain, every transaction is tracked, so all the vaccines that enter the chain through the central government are tracked all the way down to the hospitals receiving it, hence no chances of corruption in between the authorities.
  • All the transactions for a specific hash address can be seen available publicly to everyone, to make the taxpayers see where their tax is being invested.

Let’s get to the building part!

Installing Thanos Wallet:

  1. Our first step would be to install the Thanos Wallet extension. You can get that from here.
  2. Once installed, create a new Wallet.

  1. For future use purposes, take the backup of your seed phrase and then continue.

  1. Now go to Tezos faucet to get a Testnet account for testing the Dapp with Thanos wallet and download the JSON file.

  1. Select import account and upload the Faucet file.

After the confirmation, you will receive some amount of XTZ in Delphi Testnet account.

Now we are ready to build the CoviDapp!

Building the Dapp

For building a Dapp we first need smart contracts. Smart contracts help in designing custom protocols for the transactions. Tezos smart contracts are based on Michelson Language and for a beginner, it will be really difficult to get started with it. So, to overcome this problem SmartPy is there which is a Python-based library specifically developed to design Michelson contracts. It has good documentation. Also, SmartPy comes with a web-based IDE so you don’t have to install anything in the local system. Since we are designing a COVID-19 distribution system we will need to develop three different contracts, one for Central Government, one for State Government & one for Hospital.

All the codes are available in my CoviDapp GitHub Repository.

sukesh2000/coviDapp

Designing a contract for Central Government:

There will be three main entry points in the contract,

  1. For storing the requests from the State Government, this entrypoint will be triggered by the State Government.
  1. For changing the vaccine count.
  1. For transferring the vaccine, this entrypoint will trigger another entrypoint in the State Government’s contract which will update the vaccine count available with the State Government automatically.

Designing a contract for State Government:

In the State Government’s contract, there will be four main entrypoints,

  1. For updating the vaccine count. This will be triggered by the Central Government.
  1. For requesting the vaccines from the Central Government, this entrypoint will trigger another entrypoint in the Central Government’s contract.
  1. For storing the hospital’s request, this entry point will be triggered by the hospital.
  1. For transferring the vaccines to the hospital.

Designing a contract for Hospital:

In the Hospital’s contract, there will be two main entrypoint.

  1. For requesting vaccines from the State Government.
  1. For updating the vaccine count.

Now we are done with designing the contracts for the Vaccine Distribution!

Deploying the Dapp

For deploying the Dapp, we will first need to generate the Michelson Contract which can be done from the SmartPy IDE itself and then deploy the generated contract in Delphi Testnet. Once the contract is deployed our next step is to create a React App for deploying the Dapp on a web server. Since all the Javascript files contain nearly similar code I’ll be explaining only for the State Government’s website. To develop the React App you will need to main libraries, Taquito & Thanos Wallet.

  1. First, we will need to create a config.json file which contains the configuration details of the contract. Update the config.json file with the contract address of the generated contract.
  1. Now we will need to create a JavaScript file that will be used to connect to the local Thanos Wallet by the Dapp.
  1. A Javascript file that will be used to interact with the contract and trigger the entrypoints.
  1. A client-side application that will be used by the State Government hospital to interact with the Dapp. Code for the same can be found here.

sukesh2000/coviDapp

A similar procedure can be repeated to develop the React App for the Central Government and the Hospital.

Hurray, we are done with developing the Dapp that can be used to record the details of the vaccine that is being distributed!!!

Furthermore, if you would like to display the details of the transactions happening between the Central Government, State Government & Hospital, you can use the TZKT API.

TzKT API Documentation

Code for the same can be found in my repository.

sukesh2000/coviDapp

This project was built by me during the Python Week Hackathon.

Special thanks to Tezos India Foundation and GD Soumya, Blockchain Developer Intern at Tezos India for helping us develop this Dapp.

Project Contributors:

Join Coinmonks Telegram group and learn about crypto trading and investing

Also, Read

Get Best Software Deals Directly In Your Inbox


Discussion (0)